Standard Access navigation buttons

Microsoft Access provides basic navigation buttons as standard on any form you design and you have to set the Navigation Buttons property to "No" in order to remove them. These are popular with users because the buttons are a familiar way of moving between records.

Standard navigation buttons on a form. Although the Access navigation buttons are familiar, they are not perfect. Some users find that they are just too small to be usable. This is a problem whenever you have users who don't have fine control over the movement of the mouse. This might be because the users are older or it might be because they're trying to use a laptop in awkward surroundings.

The solution for both these categories of user is to suppress the built-in buttons and to provide some nice, large buttons as a replacement as in the example opposite. This is easy enough because the Control Wizard will automatically write the VBA code for the buttons' click events.

Although it's easy enough, creating these buttons adds extra work to the design of every form and your application will look rough and unfinished if the buttons aren't absolutely the same on every form.

The answer is to use a subform.

Navigation buttons on a subform

It's not obvious from the first screenshot but the five navigation buttons are actually held on a subform. There's no reason for the user to know about this and it's very easy to hide the edges of the subform by setting its Border Style property to "Transparent". This subform can be used on every form in a database, saving you a lot of time and giving a nice consistent look to the application.

Access navigation buttons in a sub form. The navigation subform is very simple. It has no Record Source of its own and just holds the five buttons, each with a snippet of VBA code behind it.

The code behind the buttons is based on the standard code that is generated by the Control Wizard. The only additions are needed because the subform is never navigating through its own data. Instead we have to specify another parameter in the calls to DoCmd.GotoRecord so that it will move through the data associated with its parent form.

Similarly we have to tell the Close button to close the parent form rather than closing its own form and any extra buttons you might like to add, such as "Add", "Find" or "Delete" would need similar modifications.

VBA code

This is a simplified version of the code and lacks any error handling. A real world form has to check for beginning and end of file so that the user can't run out of records.

Private Sub closeButton_Click()
  DoCmd.Close acForm, Me.Parent.Name
End Sub

Private Sub Sub firstButton_Click()
  DoCmd.GotoRecord acDataForm, Me.Parent.Name, acFirst
End Sub

Private Sub Sub previousButton_Click()
  DoCmd.GotoRecord acDataForm, Me.Parent.Name, acPrevious
End Sub

Private Sub Sub nextButton_Click()
  DoCmd.GotoRecord acDataForm, Me.Parent.Name, acNext
End Sub

Private Sub Sub lastButton_Click()
  DoCmd.GotoRecord acDataForm, Me.Parent.Name, acLast
End Sub

Access 2007

As a bonus in Access 2007, you can set the Auto Repeat property to "Yes" on the "Previous" and "Next" buttons and the database will keep moving through the records as long as the user keeps the mouse button pressed. Obviously, you don't need an autorepeat on "First" and "Last".

A minor problem with Access 2007 is that the Control Wizard generates an Access macro rather than program code in Visual Basic

More tips from Alvechurch Data

More tips from Alvechurch Data

Access Switchboard Forms

Forms in the Access Switchboard Manager.

Read More

Access Switchboard

Using the Switchboard Manager to create an Access switchboard.

Read More

Altering an Access Switchboard

Improving the appearance of a switchboard in an Access database.

Read More