Record selectors

  • Thread starter Thread starter vb_Dumb
  • Start date Start date
V

vb_Dumb

I have a form i have been working on for a while now. I disabled the
navigation buttons and put add record and a next and back but I want
to put some kind of code on the next button so that it will not go to
a new record. If anyone can tell me how to do this that would be
awesome. Thanks in advance!

Dan
 
With the form in design view, select the properties of the actual form.
(right click the little box that is formed by the junction of the two rulers.
Now set allow additions to No.

Your selectors will not now go past the last record. You may get an error
stating, "You Cannot goto the Specified Record"

You can overcome that on your command Button by disabling the Error
Description.

Private Sub Command15_Click()
On Error GoTo Err_Command15_Click


DoCmd.GoToRecord , , acNext

Exit_Command15_Click:
Exit Sub

Err_Command15_Click:
'MsgBox Err.Description (Now Disabled with ' typed in front)
Resume Exit_Command15_Click

End Sub

I hope this answers your question????

Please let me know if you have problems

Regards

Mike B
 
Sorry, I have just re-read your problem. I didn't notice that you had a add
new record button. With this, you cannot set the form's Allowadditions to No.
but there is a modification you can do to the buttons as follows:

'Goto Next Record (Turn off allow additions this will prevent the button
going to a new record)

Private Sub Command15_Click()
On Error GoTo Err_Command15_Click

Me.AllowAdditions = False
DoCmd.GoToRecord , , acNext

Exit_Command15_Click:
Exit Sub

Err_Command15_Click:
'MsgBox Err.Description (Error Message disabled by ' placed in front)
Resume Exit_Command15_Click

End Sub

'Add a new record (Turn on Allow additions, goto new records, and then turn
off allow additions)

Private Sub Command16_Click()
On Error GoTo Err_Command16_Click

Me.AllowAdditions = True
DoCmd.GoToRecord , , acNewRec
Me.AllowAdditions = False
Exit_Command16_Click:
Exit Sub

Err_Command16_Click:
MsgBox Err.Description
Resume Exit_Command16_Click

End Sub

I hope this helps????

Regards again

Mike B
 
Back
Top