EOF getting "You can't go to the specified record"

D

Dave

I have a button that moves user to the next record. After the last record,
user gets the following error message.

"You can't go to the specified record. "

how can I modify the following code to give a message to the user when it
is the end of the file? I used the button wizard to create this.

Private Sub cmd_NextWord_Click()
Dim rst As ADODB.recordset
Set rst = New ADODB.recordset
Dim intAnswer As Integer

On Error GoTo Err_cmd_NextWord_Click
DoCmd.GoToRecord , , acNext
Exit_cmd_NextWord_Click:
Exit Sub
Err_cmd_NextWord_Click:
MsgBox Err.Description
Resume Exit_cmd_NextWord_Click
End Sub
 
G

Guest

I had the same issue, and what I did was add the code below to Form_Current()

Me.FirstRecordButton.Enabled = (Me.CurrentRecord > 1 )
Me.PreviousRecordButton.Enabled = (Me.CurrentRecord < 1)
Me.RecordsetClone.Movelast 'could be any ie: Movefirst
Me.NextRecordButton.Enabled = (Me.CurrentRecord < _
Me.RecordsetClone.RecordCount)
Me.LastRecordButton.Enabled = (Me.CurrentRecord < _
Me.RecordsetClone.RecordCount)


This disables the buttons when first or last record is reached thus no more
EOF messages.

Cheers
 
G

Guest

Typo, sorry, second line should be:

Me.PreviousRecordButton.Enabled = (Me.CurrentRecord > 1)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top