Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MoveNext Key EOF recognition

Status
Not open for further replies.

BusMgr

IS-IT--Management
Joined
Aug 21, 2001
Messages
138
Location
US
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
 
try

With rst

.MoveLast
.MoveFirst

Do While Not rst.EOF

.MoveNext

Loop
 
Now it won't do anything! ie it won't move records at all.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top