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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

recordset end of file 3

Status
Not open for further replies.

striker73

MIS
Jun 7, 2001
376
US
I am programming my own navigation button with VBA, but I am having trouble with the syntax for the end of the recordset. I want the code to say:

If (Me.Recordset.MoveNext.EOF=True) Then
MsgBox ("You're already at the end of the list.")
Else
DoCmd.GoToRecord , , acNext
End If

However, I get an errory saying "object required." Any ideas? Thanks!!
 
Well, I don't think that EOF is a valid property of MoveNext. You can either have Me.Recordset.MoveNext, which performs an action, or Me.Recordset.EOF, which returns true if you are at the end of the recordset.

So you should use the former to move to the next record, and the latter to check whether you have reached the end of the recordset. (Hope this makes sense).

Also, presumably "Recordset" represents a valid recordset variable that you have opened using the OpenRecordset method? Have fun! :eek:)

Alex Middleton
 
Private Sub cmdNext_Click()
On Error GoTo Err_cmdNext_Click

DoCmd.GoToRecord , , acNext

Exit Sub

Err_cmdNext_Click:
If Err.Number = 2105 Then
MsgBox "You have reached the end of the file.", vbOkOnly
End If

End Sub



This will do the same thing your trying to do but a LOT simpler. Error number 2105 is the number called for record movement errors. I know this because I have a table that logs all errors. Check out all the methods of the DoCmd object. It has a lot to offer.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top