Check a content of a text box

J

John B

In a form I have a text box that contains the following text: X5818.
I would like to force the user to fill completly the text with the letter X
and the four digit if another text box has the value "Files copies".
Many thanks for your help.
Regards
John
 
W

Wayne Morgan

In the BeforeUpdate event of the textbox you could run a check similar to
the following.

If Me.NameOfOtherTextbox = "Files Copies" Then
If Not (Left(Me.NameOfThisTextbox.Text, 1) = "X" And
IsNumeric(Right(Me.NameOfThisTextbox.Text,4)) And
Len(Me.NameOfThisTextbox.Text)) = 5 Then
MsgBox "Invalid Entry. Try Again.", vbOkOnly+vbExclamation, "Invalid
Entry"
Cancel=True
End If
End If
 
J

John B

Many thanks for your help.

Regards
John

Wayne Morgan said:
In the BeforeUpdate event of the textbox you could run a check similar to
the following.

If Me.NameOfOtherTextbox = "Files Copies" Then
If Not (Left(Me.NameOfThisTextbox.Text, 1) = "X" And
IsNumeric(Right(Me.NameOfThisTextbox.Text,4)) And
Len(Me.NameOfThisTextbox.Text)) = 5 Then
MsgBox "Invalid Entry. Try Again.", vbOkOnly+vbExclamation, "Invalid
Entry"
Cancel=True
End If
End If

--
Wayne Morgan
MS Access MVP


letter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top