Help and Support
 

powered byLive Search

ACC: How to Create Custom Navigation (VCR) Buttons on a Form

Retired KB ArticleThis article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.
Article ID:104683
Last Review:May 6, 2003
Revision:2.0
This article was previously published under Q104683
On This Page

SUMMARY

Advanced: Requires expert coding, interoperability, and multiuser skills.

The navigation (VCR) buttons that appear on a form's horizontal scroll bar provide a convenient way of navigating among records.

The following information describes how to create custom navigation buttons on your own forms.

This article assumes that you are familiar with Access Basic and with creating Microsoft Access applications using the programming tools provided with Microsoft Access. For more information on Access Basic, please refer to the "Introduction to Programming" manual in Microsoft Access version 1.x, or the "Building Applications" manual in version 2.0.

Back to the top

MORE INFORMATION

The following sample module demonstrates Access Basic functions that can be used to create custom buttons for navigating among first, last, previous, and next records on a form. Functions are provided to navigate through forms as well as subforms.

To create custom navigation buttons on a form, create a new module with the following Access Basic code:
   '*******************************************
   ' MODULE DECLARATION SECTION
   '*******************************************
   Option Explicit
   Dim RetVal As Variant

   '*******************************************
   ' MODULE FUNCTIONS
   '*******************************************

   Function GotoFirstRecord ()
      RetVal = GotoRecord(A_FIRST)
   End Function

   Function GotoLastRecord ()
      RetVal = GotoRecord(A_LAST)
   End Function

   Function GotoNextRecord ()
      RetVal = GotoRecord(A_NEXT)
   End Function

   Function GotoPrevRecord ()
      RetVal = GotoRecord(A_PREVIOUS)
   End Function

   Function GotoFirstSubRecord (SubControlName As String)
      DoCmd GoToControl SubControlName
      RetVal = GotoFirstRecord()
   End Function

   Function GotoLastSubRecord (SubControlName As String)
      DoCmd GoToControl SubControlName
      RetVal = GotoLastRecord()
   End Function

   Function GotoNextSubRecord (SubControlName As String)
      DoCmd GoToControl SubControlName
      RetVal = GotoNextRecord()
   End Function

   Function GotoPrevSubRecord (SubControlName As String)
      DoCmd GoToControl SubControlName
      RetVal = GotoPrevRecord()
   End Function

   Function GotoRecord (Direction)
      On Error Resume Next
      DoCmd GoToRecord , , Direction
   End Function
				

Back to the top

How to Use the Custom Navigation Functions on a Form

The steps listed below demonstrate how to use the Access Basic functions detailed above to add custom navigation buttons to the Orders and the Orders Subform forms in the sample database NWIND.MDB included with Microsoft Access:
1.Open the Orders form in Design view.
2.Create four buttons on the form to facilitate navigation among the Orders records. Place these buttons side by side, with the following properties:
      Command Button : btnGotoFirstRecord
         Caption: <<
         OnClick: =GotoFirstRecord()

         NOTE: In version 1.x, the OnClick property is called the OnPush
         property.

      Command Button : btnGotoPrevRecord
         Caption: <
         OnClick: =GotoPrevRecord()

      Command Button : btnGotoNextRecord
         Caption: >
         OnClick: =GotoNextRecord()

      Command Button : btnGotoLastRecord
         Caption: >>
         OnClick: =GotoLastRecord()
						
3.Create four buttons on the Orders Subform form to facilitate navigation among the records. Place these buttons side by side, with the following properties:
      Command Button : btnGotoFirstSubRecord
         Caption: <<
         OnClick: =GotoFirstSubRecord("Orders Subform")

      Command Button : btnGotoPrevSubRecord
         Caption: <
         OnClick: =GotoPrevSubRecord("Orders Subform")

      Command Button : btnGotoNextSubRecord
         Caption: >
         OnClick: =GotoNextSubRecord("Orders Subform")

      Command Button : btnGotoLastSubRecord
         Caption: >>
         OnClick: =GotoLastSubRecord("Orders Subform")
						
NOTE: These buttons can be placed on the main form or on the subform. The argument being passed to the function ("Orders Subform") is the name of the subform control.

Back to the top


APPLIES TO
Microsoft Access 1.0 Standard Edition
Microsoft Access 1.1 Standard Edition
Microsoft Access 2.0 Standard Edition

Back to the top

Keywords: 
kbhowto kbusage KB104683

Back to the top

Article Translations

 

Other Support Options

  • Need More Help?
    Contact a Support professional by Email, Online or Phone.
  • Customer Service
    For non-technical assistance with product purchases, subscriptions, online services, events, training courses, corporate sales, piracy issues, and more.
  • Newsgroups
    Pose a question to other users. Discussion groups and Forums about specific Microsoft products, technologies, and services.