Disable Navigation Buttons

jsic1210

Registered User.
Local time
Today, 01:54
Joined
Feb 29, 2012
Messages
188
I'm trying to disable command buttons if I'm at the first or last record. So, for example, If I'm at the very first record on a form, I want the Previous and First navigation buttons to be disabled. I'm not having any luck with EOF and BOF. I've also tried using AbsolutePosition and RecordCount. Does anybody have any advice on how to do this? Thanks! Here is one thing I've tried:
Code:
Private Sub Form_Current()
'Disable Buttons
Dim rst As Recordset
    If rst.BOF Then
        Me.btnPrevious.Enabled = False
    Else
        Me.btnPrevious.Enabled = True
    End If
    
End Sub
 
Try this;

Code:
Private Sub Form_Current()

With Me
    !btnPrevious.Enabled = .CurrentRecord <> 1
    !btnNext.Enabled = .CurrentRecord <> .RecordsetClone.RecordCount
End With

End Sub
 
That worked. Thanks! :D
 
Just a quick follow-up question: Will it not work if the form has a subform? I actually have a couple nested subforms. It's form>subform1>subform2>subform3. Subform2 and subform3 have navigation buttons, but the "On Current" code doesn't work for Subform2.
 

Users who are viewing this thread

Back
Top Bottom