Previous Page
Next Page

Hack 78. Build a Secret Developer Backdoor into Your Applications

Keep users out of your design while letting yourself in the easy way.

Some users are a little too curious for their own good. Left to their own devices, they will explore your database's design. A few approaches exist to combat this. You can turn on security, convert the database to a read-only .mde version, or just remove the ability to get to the design elements.

This last option, although not as robust as using Access security, is a common way to keep users on the up and up. Setting the following options in Startup Options, shown in Figure 8-7, helps make it hard for users to get into the database design:

  • Set the opening form.

  • Uncheck the Display Database Window checkbox.

  • Uncheck the Allow Built-in Toolbars checkbox.

  • Uncheck the Allow Toolbar/Menu Changes checkbox.

Figure 8-7. Changing startup options


In the form design, you can implement the following additional settings:

  • Set the Shortcut Menu property to No.

  • Set Allow Design Changes to Design View Only.

  • Assign a custom menu bar that doesn't provide a way to access design elements.

This will keep most users focused on their work. Unfortunately, it might also mean you just made it more difficult for you to get into the database design. This hack builds a hidden shortcut that only you, the developer, know about. This shortcut takes you directly to the database's design elements.

Figure 8-8 shows a form in Design mode. A command button is strategically placed where you wouldn't think to click. You can see it in the upper-lef corner of the form. It doesn't look like a regular button, although it is. The transparent property has been set to Yes, which makes it look flat. Any caption disappears as well when the button is transparent. Therefore, it really appears as just the outline of a rectangle.

Figure 8-8. A form with a transparent button


The button has code inside its double-click event. A double-click event is never really used for buttons because everyone expects that a single button click will perform an action. When the form is in View mode, the button is invisible. Its Visible property is set to true, but the transparency overrides that.

Note that the mouse pointer doesn't change when the user passes it over the invisible button. The button is enabled, though. A user could accidentally click it without knowing it. Therefore, using the double-click event instead of the single-click event serves as a safeguard. This approach isn't foolproof, but it does keep stray clicks from running any code.

8.8.1. The Code

When you double-click the transparent button, the following code runs to ask for a password:

  Dim pw As String 
  pw = InputBox$("Enter Password", "Password")
  If pw = "Access Rocks!" Then
    DoCmd.SelectObject acTable, , True
  Else
  MsgBox "Incorrect Password"
  End If

If the password entered is correct, the database window is displayed.

Figure 8-9 shows the form in View mode after the button has been double-clicked. The button itself isn't visible; you need to know where it is to double-click it.

Figure 8-9. Entering a password to open the database window


    Previous Page
    Next Page