Link to home
Create AccountLog in
Avatar of Cyprexx IT
Cyprexx IT

asked on

Field Question

How can I make Make input field so it takes only 6, 13, or 17 digits.  Any other number count should get flagged.

how would i accomplish this?
Avatar of GRayL
GRayL
Flag of Canada image

Can it be a text/string field?
In the AfterUpdate event of your TextBox, you can try this:

If Len(Me.YourFieldName) = 6 Or Len(Me.YourFieldName) = 13 Or Len(Me.YourFieldName)= 17 Then

MsgBox "ok"

Else

MsgBox "not ok"

End If

Hope this helps,
Daniel
Use VBA.  Put code into the after update event.  Use an IF or CASE statement to compare length of value.  You can pop-up a message if you want to tell the user they entered incorrectly.
ASKER CERTIFIED SOLUTION
Avatar of mbizup
mbizup
Flag of Kazakhstan image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
In the Validation Rule of the text box enter:

Like "######" Or Like "#############" Or Like "#################"

The # forces a numeric digit to be entered.  The number of #'s dictates the length.  I take it that you only want numeric digits to be entered.
"numeric digits "

Are there another kind of digits ?

Otherwise, I vote for the Validation Rule :-)

mx

GRayL --- Duh!!!!  You are absolutely correct!  I didn't even think about using multiple validation criteria.
Did you select the correct Answer, based on your last comment ?
I gotta stop raking leaves.  Missing out on chances to defend myself ;-)