Form Data Validation

mjohnson1105

New member
Local time
Today, 05:13
Joined
Jun 6, 2013
Messages
8
Hi, I would like to write some code to validate that when a user enters data into a text field, the user must enter 4 digits. Any help would be greatly appreciated. Thanks.
 
Try something like:
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
If Len(Me.[B][COLOR="Red"]YourTextbox[/COLOR][/B]) <> 4 Then
    Cancel = True
    MsgBox "Please enter four digets."
    Me.[COLOR="red"][B]YourTextbox[/B][/COLOR].SetFocus
End If
End Sub
in the forms Before Update event.
 
Thanks Bob! That was easy enough....
 
Glad to be of help. Perhaps you would mark the post as "Solved".
 

Users who are viewing this thread

Back
Top Bottom