Field Validation

AndyShuter

Registered User.
Local time
Today, 13:40
Joined
Mar 3, 2003
Messages
151
I have little problem that I am struggling to find an answer to. When I output a piece of data from my text box, it must be either 10 or 11 characters long when it goes into the receiving data base. I just wonedered if anyone knew of a way of validating the text box to ensure that it met this criteria before output. Input mask is not an option, as other receiving databases may not require the validation.

Hope I explained that OK

I'm using Office 2003 by the way
 
Validation

Try something like this in the Before Update Event of the field:

If Len(Me.yourfield) < 10 Or Len(Me.yourfield) > 11
Me.yourfield = Left(Me.yourfield, 11)

'message box optional
MsgBox "Text must be 10 or 11 characters, vbOKOnly, ""

'set focus to another field
Me.otherfield.setfocus
'set focus back to the field field
Me.yourfield.setfocus
Exit Sub
Else
End If
 
Thanks

Works great, thanks mate
 

Users who are viewing this thread

Back
Top Bottom