Validation Rule Help (entry must be 7 digits) (1 Viewer)

gcormier

Registered User.
Local time
Today, 03:24
Joined
May 31, 2000
Messages
13
I'm sure this is a simple one for most... but I am stumped. What is the validation syntax to limit a user to a 7 digit entry in a form field? ( I want a user to enter a code that must be 7 digits in length) Thanks in advance. -GAC
 

R. Hicks

AWF VIP
Local time
Yesterday, 21:24
Joined
Dec 23, 1999
Messages
619
Here is one way of doing it.
Use the Before Update event of the txtbox you are using for the entry:

Private Sub YourTextBox_BeforeUpdate(Cancel As Integer)
Dim strMsg As String, strTitle As String
strMsg = "This Entry Must be a 7 Digit Numeric Value."
strTitle = "Date Entry Error"

If Len(Me.ActiveControl) <> 7 Or Not IsNumeric(Me.ActiveControl) Then
MsgBox strMsg, vbInformation + vbOKOnly, strTitle
Cancel = True
End If
End Sub

HTH
RDH

[This message has been edited by R. Hicks (edited 08-31-2000).]
 

gcormier

Registered User.
Local time
Today, 03:24
Joined
May 31, 2000
Messages
13
Answered my own question. Thought I'd post it for anyone with similar needs. In validation rule field enter: Like "???????". You can put your cursor in the validation rule field and hit F1 and the answer appears before you. -GAC
 

Users who are viewing this thread

Top Bottom