Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

iif query problem 1

Status
Not open for further replies.

ksbigfoot

Programmer
Apr 15, 2002
856
CA
I am not sure if an iif is the solution to my problem.
I have a query that looks at two combo boxes. What I want to do is use only the combo boxes that are populated in my query. If they are null, don't include them in query.
I would like to add in the Where statement something like
Iff IsNull([Forms]![PropertyEntry]![PrimaryTownID]), <> PrimaryTownID, (Don't do anything)

I am not sure how to write this.
Here is my query:
Code:
SELECT [RuralAreas].[RuralAreasName], Municipalities.MunicipalitiesID
FROM RuralAreas INNER JOIN Municipalities ON RuralAreas.RuralAreasID = Municipalities.RuralAreasID
WHERE Municipalities.MunicipalitiesID)<>[Forms]![PropertyEntry]![PrimaryTownID] 
And Municipalities.MunicipalitiesID)<>[Forms]![PropertyEntry]!![SecondaryTownID]
Thanks
 
Something like this ?
WHERE Municipalities.MunicipalitiesID)<>Nz([Forms]![PropertyEntry]![PrimaryTownID],0)
And Municipalities.MunicipalitiesID)<>Nz([Forms]![PropertyEntry]![SecondaryTownID],0)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Hi PH,

Thanks for the help. Sorry if I sound confused but what is Nz?

Thanks
 
Hi PH,

Sorry, I looked it up NZ in the help file.
I will try and see if it works.

Thanks
 
Hi PH,

Worked like a charm.

Thanks again and a star to you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top