Button Problem

StacyStacy

A "Californian" at heart!
Local time
Yesterday, 21:28
Joined
Jan 29, 2003
Messages
159
I added a button "previous record". Whenever I click the button to go to the previous record(s), it only advances to the first previous record but will not continue. I don't have that problem with the "next record" button. Here's the code. What went wrong?

Private Sub GOTO_PREVIOUS_RECORD_Click()
On Error GoTo Err_GOTO_PREVIOUS_RECORD_Click

DoCmd.GoToRecord , , acLast

Exit_GOTO_PREVIOUS_RECORD_Click:
Exit Sub

Err_GOTO_PREVIOUS_RECORD_Click:
MsgBox Err.Description
Resume Exit_GOTO_PREVIOUS_RECORD_Click

End Sub
 
StacyStacy said:
What went wrong?

DoCmd.GoToRecord , , acLast


DoCmd.GoToRecord , , acLast goes to the last record.

The five most used are:

DoCmd.GoToRecord , , acFirst
DoCmd.GoToRecord , , acLast
DoCmd.GoToRecord , , acPrevious
DoCmd.GoToRecord , , acNext
DoCmd.GoToRecord , , acNewRec

I'm sure you can work out your mistake from that... :cool:
 
StacyStacy said:
I added a button "previous record". Whenever I click the button to go to the previous record(s), it only advances to the first previous record but will not continue. I don't have that problem with the "next record" button. Here's the code. What went wrong?

Private Sub GOTO_PREVIOUS_RECORD_Click()
On Error GoTo Err_GOTO_PREVIOUS_RECORD_Click

DoCmd.GoToRecord , , acLast

Exit_GOTO_PREVIOUS_RECORD_Click:
Exit Sub

Err_GOTO_PREVIOUS_RECORD_Click:
MsgBox Err.Description
Resume Exit_GOTO_PREVIOUS_RECORD_Click

End Sub

The code above will navigate to the last record in the recordset. To go to the previous record alter it to read:

Code:
DoCmd.GoToRecord , , acPrevious
 

Users who are viewing this thread

Back
Top Bottom