If,ElseIf or Case Statements

forms_are_nightmares

Registered User.
Local time
Today, 05:35
Joined
Apr 5, 2010
Messages
71
I've searched through the old threads and can't find anything that solves my problem. I have multiple conditions that need to run and produce a result. I've tried Case statements and IF ElseIf statements. Essentially, when I run them, nothing happens, though I know data exists to satisfy the conditions. Any help is appreciated.

Here's my code:

If Exterior.Value = "Complete Lawn Care" And Me.statecmbo <> "" And Me.zipcmbo <> "" Then
Me.Filter = "[Vendor State] Like '" & Nz(statecmbo.Value, "") & "*' And [Vendor Zip] Like '" & Nz(zipcmbo.Value, "") & "*' And [Complete Lawn Care] Like '" & Nz(Yes) & "*'"
Me.FilterOn = True

ElseIf Exterior.Value = "Complete Lawn Care" And Me.statecmbo <> "" And IsNull(Me.zipcmbo) Then
Me.Filter = "[Vendor State] Like '" & Nz(statecmbo.Value, "") & "*' And [Complete Lawn Care] Like '" & Nz(Yes) & "*'"
Me.FilterOn = True


ElseIf Exterior.Value = "Irrigation (installation / repair" And Me.statecmbo <> "" And Me.zipcmbo <> "" Then
Me.Filter = "[Vendor State] Like '" & Nz(statecmbo.Value, "") & "*' And [Vendor Zip] Like '" & Nz(zipcmbo.Value, "") & "*' And [Irrigation (installation / repair] Like '" & Nz(Yes) & "*'"
Me.FilterOn = True

ElseIf Exterior.Value = "Irrigation (installation / repair" And Me.statecmbo <> "" And IsNull(Me.zipcmbo) Then
Me.Filter = "[Vendor State] Like '" & Nz(statecmbo.Value, "") & "*' And [Irrigation (installation / repair] Like '" & Nz(Yes) & "*'"
Me.FilterOn = True
EndIF
 
if nothing is happenning, then your filter statement is not registering. take a look at the property in the help menu for example syntax
 
And this is a duplicate post essentially. (don't post the same question more than once, please)
 
just to make sure:
null is not the same as ""
 
Also, the thought occurs that you have this:

[Complete Lawn Care] Like '" & Nz(Yes) & "*'"

You would need to use quotes around YES and why the NZ for yes? Yes is not a field and would never be null. You can use

[Complete Lawn Care] Like '*Yes*'

if [Complete Lawn Care] has extra words in there. But if it is Yes or No then just

[Complete Lawn Care] = 'Yes'

would be the way to go.
 

Users who are viewing this thread

Back
Top Bottom