Here is a routine I use for custom record navigation buttons. Add a tiny text control named txtFocus. This will be used to take the focus off of the buttons. Name your buttons the way I did (cmdGoFirst, cmdGoLast, etc). Call the routine in your form's Current
event and each nav button Click event.
Public Sub CheckPosition(frm As Form, ParamArray ctrls())
'Purpose : Enable/disable nav buttons.
' txtFocus is a textbox that is used only to get
' Focus during enabling/disabling. It is just a
' dot on the form plced near nav buttons.
'DateTime : 11/4/2013 12:08
'Author : Bill Mosca
Dim lngRecNum As Long
Dim lngRecCt As Long
Dim x As Integer
lngRecNum = frm.CurrentRecord
lngRecCt = DCount("*", "DataExtractionAccessLog")
frm.txtFocus.SetFocus
frm.cmdGoFirst.Enabled = lngRecNum <> 1
frm.cmdGoLast.Enabled = lngRecNum <> lngRecCt
frm.cmdGoNext.Enabled = lngRecNum <> lngRecCt
frm.cmdGoPrev.Enabled = lngRecNum <> 1
frm.cmdGoNew.Enabled = lngRecCt <> 0
'No Additions should disable "New" button
If frm.AllowAdditions = False Then
frm.cmdGoNew.Enabled = False
End If
'If any cbo's or lst's have a user-defined function for RowSourceType
'they will need to be requeried.
If Not IsNull(ctrls) Then
For x = 0 To UBound(ctrls)
If ctrls(x).ControlSource = "" Then ctrls(x) = Null
ctrls(x).Requery
Next
End If
End Sub