stay on current record if error

  • Thread starter Thread starter mcnews
  • Start date Start date
M

mcnews

i am trying to keep the user from adding a new record if an error
occurs on the current new record.
i used the following code but it doesn't get me there:

Private Sub UniqueID_AfterUpdate()
If UniqueID.Value = SpecimenID.Value Then
Dim longRec As Long
longRec = Me.Recordset("ID")
MsgBox "You scanned the same barcode twice!", vbCritical, "Scan
Error"
DoCmd.GoToRecord , , acGoTo, longRec
UniqueID.SetFocus
End If
End Sub

even tho longRec contains the correct record number and executing the
goto from the command window works.

?

tia,
mcnewsxp
 
Use the Before Insert method of the form. If the new record fails
validation, set the Cancel argument to True. It will stop the update and
stay on the record.
 

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

Back
Top