Previous and Next Buttons

That Guy

New member
Local time
Today, 12:47
Joined
Feb 10, 2013
Messages
5
I have added Previous and Next buttons to a contacts template I have downloaded from the Microsoft site and they work fine.

However, when you get to the last record and click next you get a message saying something like "Cannot Complete Operation" etc. Is there any way to suppress these messages so the button will simply do nothing when it gets to the last record.

Its also the same with the previos button when you get to the first record.

Thanks in Advance.
 
You need to add validation to the buttons eg. If you're on the last record the next record should go back to the start. Or just do nothing as you said.
I can't really help without seeing your button code.
 
I'm going to guess you probably have something along the lines of;
Code:
DoCmd.GoToRecord acDataForm, "YourFormName", acPrevious
Which gives you an error if clicked whilst on the first record. So you could insert some Very Basic error handling, which would look like;
Code:
Private Sub [COLOR="Red"]Command6_Click()[/COLOR]

On Error GoTo [COLOR="Purple"]Err_Click6[/COLOR]
    
    DoCmd.GoToRecord acDataForm, "YourFormName", acPrevious
    
[COLOR="Purple"]Exit_Command6_Click:[/COLOR]
    Exit Sub
    
[COLOR="Purple"]Err_Click6:[/COLOR]
    Resume [COLOR="Purple"]Exit_Command6_Click[/COLOR]


End Sub

The Red section of the code will be assigned by Access and represent the reality that exists in your DB. The Purple highlighted sections should be changed to reflect your DB.
 

Users who are viewing this thread

Back
Top Bottom