Showing posts with label Access Options. Show all posts
Showing posts with label Access Options. Show all posts

Friday, 27 April 2012

Hiding the Navigation Pane with VBA

Once you have created an Access Database Application to be used by other people, it may well be important for you to prevent users from gaining access to any of its design features.  By this I mean, you may not want users to modify your tables, forms and queries etc in design view (inadvertently or otherwise).  There are a number of measures you need to take in order to secure your database against this possibility.  One of these involves preventing users from accessing the NAVIGATION PANE, a major doorway to all of your database objects.  Hiding the NAVIGATION PANE can be done with a couple of lines of VBA Code.

To use this code, you will need one of your database forms' to open automatically as your application opens. There are instructions to do this in my post on How to Display a Form Automatically. Once this is in place you can insert the following code into that form's ON LOAD event.

    DoCmd.SelectObject acTable, "tblCustomer", True
    DoCmd.RunCommand acCmdWindowHide 


The purpose of the first line of code is to select any object in the navigation pane.  We have selected one of the database tables called tblCustomer, and then set the INNAVIGATIONPANE parameter to true.  Once  a database object from the navigation pane has been selected, we can then use the DoCmd.RunCommand with the acCmdWindowHide parameter in the following line of code.  This has the effect of hiding whichever window happens to contain the selected object. 

The user can quite easily get the Navigation Pane back by pressing the F11 Access Special Key (assuming  that he or she knows about it), but this facility can be disabled.  To do this you will need to deselect the USER ACCESS SPECIAL KEYS check box in the CURRENT DATABASE section of ACCESS OPTIONS, (via the OFFICE button).

Hiding the Navigation Pane alone is not sufficient to secure a database, but it is one important part of doing so.

Friday, 9 September 2011

How to Display a Form Automatically when your Application Opens

This is a quick tip on how to automatically display a form when the user opens your Access Application.  In addition to improving User Friendliness, your database design will also appear much more professional.  The step by step instructions below will display the Switchboard form in figure 1 immediately upon the application opening.  This will give them a good start point from which to navigate your system.

Figure 1: Switchboard Form opens Automatically
when the Application Opens.
  1. Open the Database and create a Switchboard Form similar to that in figure 1 above.  Call the form frmSwitchboard.
  2. Click the MICROSOFT OFFICE button in the top right hand corner of the Access Screen.  
  3. Click the ACCESS OPTIONS button at the bottom of the open pane.  This opens the ACCESS  OPTIONS dialogue form.
  4. Select CURRENT DATABASE from the menu on the left side of the dialogue form.  This displays the Options for the Current Database (see figure 2 below).
    Figure 2: Options for the Current Database.
  5. The fourth option down from the top is DISPLAY FORM.  Click the Combo Box arrow and select frmSwitchboard from its drop down list, 
  6. Click OK to close the ACCESS OPTIONS form.
  7. Close the database.
The next time you open your application, the Swichboard is displayed automatically without the user needing to select it from the Navigation Pane.