Text feild check for pattern or if last 5 are numeric?

B

Billp

I have a text feild that has a mask of >L00000, upper case, alpha with 5 digits

If the field is in the pattern >L00000 I have a sql statement to perform.
Or option 2 is to check if the last 5 characters are numeric then get it to
do the statement. So that if the field is an empty string or null nothing
happens.

I Have,
DoCmd.SetWarnings False
Dim strsql As String


'If Not IsNumeric(Left(Me!SER_Exists, 1)) Then
'If (Me!SER_Exists) = "" Then

If Me!SER_Exists Like ">L00000" Then 'fits the text pattern

strsql = " UPDATE tblSER " & _
" SET [QuoteNumberRef] = true " & _
" WHERE [SER_ID] = " & Me!cboSER_Exists.Column(1) 'Quotes
this way as field is numeric
'Debug.Print strsql
DoCmd.RunSQL strsql
Else
'do nothing
End If

DoCmd.SetWarnings True

But the form >L00000 doesn't look right
should it be "?#####"
Because ">L00000" doesn't do anything.

Thanks in advance
 
J

John W. Vinson

If Me!SER_Exists Like ">L00000" Then 'fits the text pattern

Input masks use one syntax. LIKE wildcards use a different syntax.

The field does not contain a > character (that just forces the letter to
display in upper case, even if it's stored in lower).

Use a criterion

LIKE "[A-Z]#####"

will match strings containing a letter (upper or lower case, it's not case
sensitive) followed by five numeric digits.
 

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