Stop the next button creating new record

Steven811

Registered User.
Local time
Today, 22:55
Joined
Apr 18, 2004
Messages
133
Hi

My own nav buttons work well with the exception of the next button. I only want it to go to current records and not past them as I have another button for that function.

How would I modify the code?

Here is what I currently use:

[Private Sub cmdGotoNext_Click()
On Error GoTo cmdGotoNext_Click_Err

Screen.PreviousControl.SetFocus
DoCmd.GoToRecord , "", acNext

cmdGotoNext_Click_Exit:
Exit Sub

cmdGotoNext_Click_Err:
MsgBox Error$
Resume cmdGotoNext_Click_Exit
End Sub]

Thanks

Steven811
 
Setting the Forms "Allow Additions" property to No will stop this.
 
You can test for new record.
Code:
   Screen.PreviousControl.SetFocus
   DoCmd.GoToRecord , "", acNext
   
   If Me.NewRecord Then
      DoCmd.GoToRecord , , acPrevious
   End If
 
Help with syntax

It only displays the error message when I'm on the new/blank record and then try to move on one more record.

The buttons are on the main form and there are 2 nested subforms.

The code that I'm using is:

[Private Sub cmdGotoNext_Click()
On Error GoTo cmdGotoNext_Click_Err

Screen.PreviousControl.SetFocus
DoCmd.GoToRecord , "", acNext

If Me.NewRecord Then

DoCmd.GoToRecord , , acPrevious

cmdGotoNext_Click_Exit:
Exit Sub

cmdGotoNext_Click_Err:
MsgBox Error$
Resume cmdGotoNext_Click_Exit
End If
End Sub]

Any ideas?

Steven811
 
Since acNext works, logically acPrevious should also work.


These three lines should be placed together

If Me.NewRecord Then
DoCmd.GoToRecord , , acPrevious
End If

.
 
acPrevious works

Hi

The buttons work, first, last previous and next.

Oddly this code doesn't stop the user mving to a blank/new record

[If Me.NewRecord Then

DoCmd.GoToRecord , , acPrevious

End If]

Steven811
 

Users who are viewing this thread

Back
Top Bottom