Solved

IIF syntax, if null return all problem

Posted on 2008-10-06
4
597 Views
Last Modified: 2013-11-05
MS Access 2003
I need help with my syntax.

IIF([district1] is null, like "*" or NZ([district]), [district1])

This is my criteria, [district1] is undefined and gives a msgbox(think thats the term, pops up asking for a value).

[district] is the field for which i am trying to establish a criteria.

What i want is to return all lines unfiltered when nothing is typed into the msgbox.
what i get is this "this expression is typed incorrectly or is toocomplex to be evaluated...."

can you help please.
I'd prefer not to do this in vb but can if needed
Thank you
0
Comment
Question by:norris900
  • 2
4 Comments
 
LVL 7

Expert Comment

by:Norush
ID: 22648751
What do you want your query to do ?

Are [district] and [district1] 2 different fields and are they in the same table?
What is their datatype?
0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 50 total points
ID: 22648769
what about this:
WHERE [district] LIKE NZ([district1], '*')

Open in new window

0
 

Author Comment

by:norris900
ID: 22648812
[district] is a text field in my table

[district1] is a undefined criteria for the field [district]

e.g.
select table1.district from table1 where (((table1.district)=[district1]));

I want the query to return all data when no criteria is entered by the user in the msgbox that pops up
0
 

Author Closing Comment

by:norris900
ID: 31503353
Thanks was being a bit slow even for me on a monday morning :)
Perfect solution
0

Featured Post

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question