16. Hide Sensitive Information
Here's a quick and easy hack to hide data from prying eyes. Of course, any Access guru with enough notches in his belt will figure this one out. But ordinary users? Not likely. You can hide your tables using this approach and still retain full functionality in your application. Queries, forms, reports, macros, and code will still work, but anyone viewing the Tables tab won't find the tables you designate as hidden.
To do so, prefix your table names with USys. This acts as a flag to Access to treat the tables as a quasi-mix of system and user tables, and the ability is built in to hide or display them. Figure 2-13 demonstrates this procedure: a form is open and is clearly displaying data, but the Tables tab in the database window has no tables!
Figure 2-13. A form based on a hidden table
The form in Figure 2-13 has the record source property set to the USysClients table. In the Tools Options View menu, you'll find a setting for displaying system objects, as shown in Figure 2-14. Note that checking to display system objects makes USys tables visible.
2.5.1. An Alternative
Another way to hide objects in your database is to right-click a database object, which then displays a menu that includes a Properties option. Selecting this displays a Properties dialog, as shown in Figure 2-16. Checking the Hidden checkbox hides the object.
Figure 2-14. Selecting to display USys-prefixed tables
Figure 2-15. Displaying all USys and MSys tables
To display hidden objects, simply check "Hidden objects" in the Show section of the Options dialog box, as shown previously in Figure 2-14. But note that between prefixing object names with USys and setting the hidden attribute, you've got enough capability to be a little smart and a little dangerous. Just because you can't see objects doesn't mean they aren't there!
Figure 2-16. Setting the Hidden attribute
2.5.2. Hacking the Hack
Although this hack showed you how to hide tables and, therefore, avoid giving users access to raw data, you can hide other database objects as well. Just prefix the names of queries, forms, reports, and so on, with USys, and they magically disappear. Or, set the hidden attribute in the Properties dialog. It helps to write down the names first!
A really cool trick is to use the USys prefix, or to set the hidden attribute, for all database objects. As a result, anyone viewing the tabs in the database window will see absolutely nothing. By setting the Startup form to a form prefixed with USys, you can get the entire application running. As long as you are fully aware of how all the objects are named, you can create a complete application without a single visible object in the database window tabs. Of course, the objects become visible when they are opened, but by taking the correct measures to keep users out of your design elements, you can distribute an invisible database.