Check a content of a text box

  • Thread starter Thread starter John B
  • Start date Start date
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
 
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
 
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
 
Back
Top