Me.Recordset.Recordcount
is all that is necessary.
Also, here is a procedure that will allow you to control record selectors.
It provides four buttons. First, Previous, Next, and Last. You will have to
name the buttons to match this code or change this code to match your
buttons, or change both the code and the buttons some something entirely
different
To use it, put this in the Click event of each of the 4 buttons:
Call SetNavButtons(Me)
I put it in a standard module, so I can use it for all my forms.
One other thing, If your form contains any events that requery or reposition
your current record, you will want to include a call to it after the
reposition.
Sub SetNavButtons(SomeForm As Form)
On Error GoTo SetNavButtons_Error
With SomeForm
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