473,395 Members | 2,796 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Access 2007 - Select Query w/User-entered Parameters - "Is Null" or "Is Not Null"

Hello Ladies and Gents,

I have created a query in MS Access 2007. I want to be able to have the user define more than one parameter. If I have only one parameter AKA Year or PMC Name, the select query runs fine. But, I would like the user to have the option of defining more than one.

But wait, its more complicated. I also want the user to be able to not define the parameter (leave it blank) to retrieve all the years or all the consultants name's.

This is what I have as a query:
Query Help.pdf

I don't know where I am going wrong... I guess the SQL might help, but it is a complex query with ignoring null fields and doing some math. It's less complicated than it looks...

SQL-Problem.txt

Any help would be greatly appreciated.
Thanks!
Jan 8 '14 #1
2 1615
I figured this out by crawling around the depths of the Internet.

Either in the criteria section of the query builder use:

Expand|Select|Wrap|Line Numbers
  1. Like Iif(IsNull([PARAMETER NAME TO POP]), "*",[PARAMETER NAME TO POP])
This states that if the Parameter is null to use a wildcard to return all fields, else use what was entered by the user.

You can also edit in the WHERE clause of the SQL:
Expand|Select|Wrap|Line Numbers
  1. WHERE FieldtoFilter Like Iif(IsNull([Parameter]), "*", [Parameter])
Thought if anyone else was interested in this topic they might like the answer.

I am using this type of query to make a dynamic report.
Jan 8 '14 #2
NeoPa
32,556 Expert Mod 16PB
Morgana, there are a couple of ways of handling this generally :
  1. For string values you can say :
    Expand|Select|Wrap|Line Numbers
    1. WHERE ([Field] Like ('*'+[Parameter]) & '*')
  2. For numeric values you can say :
    Expand|Select|Wrap|Line Numbers
    1. WHERE ([Field]=Nz([Parameter],[Field]))
In the first example, for strings, if [Parameter] is null then the right side of the equation resolves to '*'. Otherwise to '*XXX*'.
In the second example the [Parameter] value is used unless null, in which case [Field] is compared to itself.
Jan 9 '14 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: arunesh | last post by:
Hi I want to get the Maximum Numbers of Tables and colums to access in select query statement Regards Arunesh
2
by: joewinch | last post by:
I know it's a newby question, but I'm stumped. In an existing MS Access 97 database, when I open up a particular Select Query in datasheet view all 6 columns of data are present. Looks good. ...
4
by: myemail.an | last post by:
Hi all, I use Access 2007 and have the following problems: when exporting banal select queries (either to Excel or to a csv file) I find that exporting often doesn't work and creates a file with...
2
by: Sport Girl | last post by:
Hi everybody , I have this query in SQL using Access 2007: SELECT Count(Opportunities.Won) AS CountOfWon, Count(Opportunities.Lost) AS CountOfLost, Count(Opportunities.) AS ,...
6
by: lisacrowe | last post by:
I have a simple database recording complaints. A crosstab query is based on a query which returns resolved complaints only. The crosstab has the field Complaint Type as a row heading and Outcome as a...
3
by: Anthony97 | last post by:
I ran this code on my access 07 db and it updates a number of records 61,425, I try and run the query in SQL Server 2005 modifying the IIf to CASE WHEN and I get a number of sytax errors. ...
2
by: brat33 | last post by:
I am trying to modify some code to create a mail merged label document within Word 2007, using a Access 2007 Parameter Field. My issue comes about when I cannot see the Parameter Query within the...
2
by: sentimental37 | last post by:
I want to create a table in access 2007 by query not in design view. My table should look like; Serial AutoNumber Name Text Country Text I am using the following query: CREATE TABLE Details...
1
by: enia atsir | last post by:
Hi, I have built a cross tab query Account_ID as row heading and month_year as column heading. I need to find if an account is at one year and not in the next month.For example: 07_2010 is not...
1
by: JD79 | last post by:
I have an access 2007 database (on an XP machine) that extracts a large set of data from an Oracle db using ODBC. The data extraction is done with a dynamic passthru query that is then called in a...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.