-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
You'll have to use the TextBox's BeforeUpdate event to validate the
data.
Private Sub txtMyText_BeforeUpdate(Cancel As Integer)
Dim strTxt As String
Dim strMsg As String
If Not IsNull(Me!txtMyText) Then
strTxt = Trim$(Me!txtMyText)
Select Case Left$(strTxt, 1)
Case "M"
If Len(strTxt) <> 14 Then
strMsg = "The data must have 14 characters"
End If
Case "A"
If Len(strTxt) <> 17 Then
strMsg = "The data must have 17 characters"
End If
Case Else
strMsg = "The data must start with an ""M"" and have " & _
"14 characters " & _
"or, start with an ""A"" and have 17 characters"
End Select
If Len(strMsg) > 0 Then
MsgBox "Invalid Data@" & strMsg & "@", vbCritical
Cancel = True
End If
End If
End Sub
MGFoster:::mgf
Oakland, CA (USA)
-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv
iQA/AwUBP6B9tYechKqOuFEgEQLzzgCgnErkf2QKhux6WPKAng35qT giiogAoKGL
XTC/4CpqbawRxlFEAGfckcV8
=47Av
-----END PGP SIGNATURE-----
pilar wrote:
Hi All,
How can I validate the entry in a text field depending on the first
letter of the string. I need to have a text box to acept 14 characters
if the first letter entered is M and 17 characters if the first letter
of the entry is A. I have been trying to do it for days. I also tried
to look for any other similar issues in the newsgroup, access help,
microsoft knowledge base...could not find any help. I'll appreciatte
any recommendation.