Using LIKE

  • Thread starter Thread starter Stephanie
  • Start date Start date
S

Stephanie

Hi. I am trying to trigger a msgbox when the Country is blank (here, this
means US) and the zipcode is less than 5 digits, but I'm not sure how to work
with "Like" correctly- the code is not triggered. I'd appreciate your
insight. Thanks.

Case 4
'5-Digit US StrZip code
If (strZip Like "#" Or strZip Like "##" Or strZip Like "###" Or strZip
Like "####") And IsNull(Country) Then
MsgBox "'" & strZip & "' is not a valid 5-digit US Zip code."
Me.PostalCode1.Value = Null
End If
 
Your syntax is wrong.
Lookup LIKE in Access Help - it's all explained there.

-Dorian
 
Your syntax is wrong.
Lookup LIKE in Access Help - it's all explained there.

-Dorian






- Show quoted text -

if len(me.strzip)< 6 and isnull(me.country) then
MsgBox "'" & strZip & "' is not a valid 5-digit US Zip code."
Me.PostalCode1.Value = Null
endif

if the fields need to be tested for numeric then you can add
isnumeric(me.strzip) = true

Ron
 
Back
Top