Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple input mask for one text field

Status
Not open for further replies.

L1sta

Technical User
Feb 22, 2007
14
GB
Hi
I'm having trouble with some Validation for one of my users. They want a text field to either contain 5 digits (e.g. 41237) OR an 'S' followed by 4 digits 0-9 (e.g. S4123)
One or the other would be easy enough but I can't find out how to make it only accept one or the other.
Thank you for any help,
Lista
 

Maybe something like...
Code:
If (Left(txtField, 1) = "S" and IsNumeric(Right(txtField, 4))) or IsNumeric(txtField) Then ...



Randy
 
In the BeforeUpdate event procedure of the control:
If Len(Me![yourTextBox]) <> 5 _
Or (Not IsNumeric(Me![yourTextBox]) _
And (Left(Me![yourTextBox], 1) <> "S" Or Not IsNumeric(Mid(Me![yourTextBox], 2)))) Then
Cancel = True
End If

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top