My Access database is linked to my SQL Server 2008. I'm trying to validate if the value entered into a textbox field (called diverNo) is a number (only numbers are allowed in this field). I want it to be validated as soon as the user leaves the field, and if the user tries to put any character which is not a number, the field will be cleaned:
Private Sub Form_Error(DataErr As Integer, Response As Integer)
If DataErr = 2113 Then
Response = acDataErrContinue
MsgBox ("Only numbers are allowed in Diver Number")
Me.diverNo = "" ' <- this line cause the error
Exit Sub
End If
End Sub
I get Runtime-error 2115 which states "The macro or function set to the BeforeUpdate or ValidationRule property for this field is preventing Microsoft Office Access from saving the data in the field."
Any suggestions to fix this?
BeforeUpdate
method, the value cannot be changed. - Mark C.