Supress Access Error in Field Validation Routine using BeforeUpdat

D

David H

I'm using the following routine to validate a value entered by a user. Access
is throwing an error - The value violates the validation rule for the field
or record.

How can I supress the error?

Private Sub inputTrailerDOTNumber_BeforeUpdate(Cancel As Integer)

If ECount("txtTrailerDOTNumber", "tblTrailerInventory",
"[txtTrailerDOTNumber] = '" & Me.inputTrailerDOTNumber & "'") = 0 Then
MsgBox "Trailer #" & Me.inputTrailerDOTNumber & " does not exist in
the database.", vbInformation
Cancel = True
Me!inputTrailerDOTNumber.Undo
End If

End Sub
 
S

Stefan Hoffmann

hi David,

How can I supress the error?
hmm, try it without the Undo...

I would use a ComboBox instead of a TextBox, so you can restrict the
input to the existing values.


mfG
--> stefan <--
 

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