View Full Version : Require specified numeric lenght or alpha input


cschoen
07-26-2007, 11:32 AM
I'm trying to create a validation rule that requires an input of 5 numeric characters OR if the entry begins with a letter it can be any length. For example if the record begins with a number the length must be 5. If it starts with a letter any length is acceptable.

Any help is appreciated!

Thank you!

WayneRyan
07-26-2007, 12:23 PM
cschoen,

You can use the BeforeUpdate event of the textbox.

Not tested, just a quick stab at it:


If IsNumeric(Left(Me.YourTextBox, 1)) Then
If IsNumeric(Me.YourTextBox) And Len(Me.YourTextBox) = 5 Then
Exit Sub
Else
MsgBox("Invalid entry.")
Cancel = True
End If
End If


hth,
Wayne

cschoen
07-26-2007, 12:28 PM
Thank you! I will give that a try.