ACC: How to Create Custom Navigation (VCR) Buttons on a FormID: Q104683
|
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.
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
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()
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")
Additional query words: scrollbar navigate goto
Keywords : kbusage FmsOthr
Version : 1.0 1.1 2.0
Platform : WINDOWS
Issue type : kbhowto
Last Reviewed: March 26, 1999