It isn't that hard. Here is some code. This first bit is the Click event for
the button to go to the first record:
Private Sub cmdFirstRec_Click()
On Error GoTo cmdFirstRec_Click_Error
On Error GoTo Err_cmdFirstRec_Click
If Me.NewRecord Then
Me.Dirty = False
Else
DoCmd.GoToRecord , , acFirst
End If
Exit_cmdFirstRec_Click:
Exit Sub
Err_cmdFirstRec_Click:
MsgBox Err.Description
Resume Exit_cmdFirstRec_Click
cmdFirstRec_Click_Exit:
On Error Resume Next
Exit Sub
cmdFirstRec_Click_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & _
") in procedure cmdFirstRec_Click of VBA Document
Form_frmAttributetable"
GoTo cmdFirstRec_Click_Exit
End Sub
--------------------------------
The rest are the same except which record you go to. Here is the line for
the Next record:
DoCmd.GoToRecord , , acNext
Then, in the current event of the form, you enable or disable the buttons
depending on where you are in the recordset:
Private Sub Form_Current()
Call SetNavButtons(Me)
End Sub
Then the code for SetNavButtons:
Sub SetNavButtons(ByRef frmSomeForm As Form)
On Error GoTo SetNavButtons_Error
With frmSomeForm
If .CurrentRecord = 1 Then
.cmdNextRec.Enabled = True
.cmdLastRec.Enabled = True
.cmdNextRec.SetFocus
.cmdFirstRec.Enabled = False
.cmdPreviousRec.Enabled = False
ElseIf .CurrentRecord = .Recordset.RecordCount Then
.cmdFirstRec.Enabled = True
.cmdPreviousRec.Enabled = True
.cmdPreviousRec.SetFocus
.cmdNextRec.Enabled = False
.cmdLastRec.Enabled = False
Else
.cmdFirstRec.Enabled = True
.cmdPreviousRec.Enabled = True
.cmdNextRec.Enabled = True
.cmdLastRec.Enabled = True
End If
End With
SetNavButtons_Exit:
On Error Resume Next
Exit Sub
SetNavButtons_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & _
") in procedure SetNavButtons of Module modFormOperations"
GoTo SetNavButtons_Exit
End Sub