Using LIKE

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
 
M

mscertified

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

-Dorian
 
R

Ron2006

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
 

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