help with a numeric field

Funkyaccess

Registered User.
Local time
Today, 14:58
Joined
Oct 8, 2009
Messages
69
Hi

I have a column in a table that is surpose to be a numeric value. Now in my form when a user types in an incorrect value eg. "abc" and leaves the field they get a very un-user friendly error message

"The value you entered isn't valid for this field.
For example, you may have entered text in a numeric field or a number that is larger than the FieldSize setting permits"

which has an ok button.

How do I stop this from happening and display my own message? I have written a vba validation function which run beforeupdate to check that the values are acceptable and I would like to check its a number as part of this function.
 
It won't happen if your validation function is working properly and preventing the record being left until it is valid.

Apply it to the Text property of the bound control on the form so it works on the current text of the control rather then the Value (default) property which is the current value held in the field of the form's Record Source.

Use the IsNumeric function to determine if it is a number.
 
Code:
Private Sub Form_Error(DataErr As Integer, Response As Integer)
If DataErr = 2113 Then 'Data entered does not match datatype of Control Source
  Response = MsgBox("Data For This Field Must Be Numerical!", vbExclamation, "Data Format is Not Numerical")
  Response = acDataErrContinue
 End If
End Sub
 

Users who are viewing this thread

Back
Top Bottom