I have a command button on a form to move through the records on the form. The problem that I am having is recognizing the EOF and raising a message, other then the MS generated error after the recordset moves through the first non-existent record.
ie the first time at EOF, a blank recordset is returned, then the next time a blank recordset is returned with a MS error message.
My code for the command button is as follows:
Private Sub cmdNextRcd_Click()
On Error GoTo Err_cmdNextRcd_Click
Dim rst As Recordset, intResponse As Integer, db As Database, i As Integer, varBookmark As Variant
Set db = CurrentDb
Set rst = db.OpenRecordset("CasingMstr", dbOpenDynaset)
With rst
'Populate the recordset
.MoveLast
.MoveFirst
varBookmark = .Bookmark
.MoveNext
If .EOF Then
MsgBox "You are at the last record & cannot go to a new record with this button.", vbExclamation, "No More Records"
.MoveLast
End If
End With
Exit_cmdNextRcd_Click:
Exit Sub
Err_cmdNextRcd_Click:
MsgBox Err.Description
Resume Exit_cmdNextRcd_Click
End Sub
Thanks for any help in advance.
BusMgr
ie the first time at EOF, a blank recordset is returned, then the next time a blank recordset is returned with a MS error message.
My code for the command button is as follows:
Private Sub cmdNextRcd_Click()
On Error GoTo Err_cmdNextRcd_Click
Dim rst As Recordset, intResponse As Integer, db As Database, i As Integer, varBookmark As Variant
Set db = CurrentDb
Set rst = db.OpenRecordset("CasingMstr", dbOpenDynaset)
With rst
'Populate the recordset
.MoveLast
.MoveFirst
varBookmark = .Bookmark
.MoveNext
If .EOF Then
MsgBox "You are at the last record & cannot go to a new record with this button.", vbExclamation, "No More Records"
.MoveLast
End If
End With
Exit_cmdNextRcd_Click:
Exit Sub
Err_cmdNextRcd_Click:
MsgBox Err.Description
Resume Exit_cmdNextRcd_Click
End Sub
Thanks for any help in advance.
BusMgr