In a form I have buttons to navigate to First Record, Next Record, Previous Record, and Last Record. When the First Record button (btnGotoFirstRecord) is clicked, the form goes to the first record, which has the First Record button disabled, because the first record is already showing (need to do the same for Previous Record, when I get this problem figured out).
This works fine, but if I then go to any other records the First Record button is still disabled. I've tried to detect that another record is being displayed in the form, to re-Enable the button, but I can't figure out which Form event to use for that--or even whether this is the best way to re-Enable a button.
This all seems like overkill, but my users will be very non-computer-savvy, and I'd like things to be as obvious as possible for them.
Here's the code I'm using for the button:
Code:
Private Sub btnGotoFirstRecord_Click()
Dim LResponse As Integer
'If the current record has been changed, warn that changes won't be saved
If Me.Dirty Then
LResponse = msgbox("Changes will not be saved.", vbOKCancel + vbDefaultButton1 + vbExclamation, "Harney County Library: Obituary Records")
If LResponse = vbCancel Then
Exit Sub
ElseIf LResponse = vbOK Then
'Undo the changes
Me.Undo
'Set focus on some other control (can't disable a control that has focus)
Me.btnGotoNextRecord.SetFocus
'Disable the First Record button
Me.btnGotoFirstRecord.Enabled = False
'Go to first record
DoCmd.RunCommand acCmdRecordsGoToFirst
End If
ElseIf Me.Dirty = False Then
Me.btnGotoNextRecord.SetFocus
Me.btnGotoFirstRecord.Enabled = False
DoCmd.RunCommand acCmdRecordsGoToFirst
End If
End Sub