MS_Access_Amature
Registered User.
- Local time
- Yesterday, 22:54
- Joined
- Nov 10, 2010
- Messages
- 56
What am I doing wrong or is there another way to go about this?
I have control buttons instead of navigation buttons on my form to go to previous and next records. I did not use the wizard just VBA code. So what I am trying to now do is make the ButtonPreviousRecord disabled when its on last record so it doesn't show me that error message you can't go to the specified record. This is my code:
Private Sub Form_Open(Cancel As Integer)
Dim RS As Recordset
With RS
If .AbsolutePosition = .RecordCount - 1 Then
Me.ButtonPreviousRecord.Enabled = False
Else
If Not .AbsolutePosition = .RecordCount - 1 Then
Me.ButtonPreviousRecord.Enabled = True
End If
End If
End With
End Sub
THis code is giving me an error message that says Object Variable or With block variable not set.
How can I fix that?
Or am I doing this thing completly wrong??
Thanks in advance!
I have control buttons instead of navigation buttons on my form to go to previous and next records. I did not use the wizard just VBA code. So what I am trying to now do is make the ButtonPreviousRecord disabled when its on last record so it doesn't show me that error message you can't go to the specified record. This is my code:
Private Sub Form_Open(Cancel As Integer)
Dim RS As Recordset
With RS
If .AbsolutePosition = .RecordCount - 1 Then
Me.ButtonPreviousRecord.Enabled = False
Else
If Not .AbsolutePosition = .RecordCount - 1 Then
Me.ButtonPreviousRecord.Enabled = True
End If
End If
End With
End Sub
THis code is giving me an error message that says Object Variable or With block variable not set.
How can I fix that?
Or am I doing this thing completly wrong??
Thanks in advance!