Command Button

E

Eva

I have a command button and when you click it, it toggles
to different forms or tables - (I'm not sure which one) -
problem is, when it reaches the last form/table, I want it
to loop back to the first form/table.

The following code is the command button code:

Private Sub Command8_Click()
On Error GoTo Err_Command8_Click

DoCmd.GoToRecord , , acNext

Exit_Command8_Click:
Exit Sub

Err_Command8_Click:
MsgBox Err.Description
Resume Exit_Command8_Click

End Sub
 
E

Elwin

The code you're running toggles to different RECORDS.
This will do what you want


Private Sub cmdMyButton_Click()
If Me.CurrentRecord = Me.RecordsetClone.RecordCount Then
DoCmd.GoToRecord , , acFirst
Else
DoCmd.GoToRecord , , acNext
End If
End Sub
 

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