473,386 Members | 1,773 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,386 software developers and data experts.

Need help with criteria for a query - want all records or selection from combo box

Col
I have a query with criteria that comes from a combo box on a form. I'd
like to set the query up so the user can either limit the criteria to
the selection in the combo box or the user can pull all records. Can't
figure out a way for the query to pull all records. Currently uses the
criteria [forms]![frmreport]![combo10]. I've tried a couple of things
to allow for the option of all records, but without any luck. Any
suggestions?

Jul 5 '06 #1
5 1801
Switch the query to SQL View (View menu, in query design.)

Locate the WHERE clause.
It will be something like this:
WHERE ((Table1.Field1) = [forms]![frmreport]![combo10])

Change it to this kind of thing:
WHERE (([forms]![frmreport]![combo10] Is Null)
OR (Table1.Field1 = [forms]![frmreport]![combo10]))

If you have several of these, it gets messy to maintain.
For an alternative, see how the Search Form works here:
http://allenbrowne.com/ser-62.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Col" <cm****@hotmail.comwrote in message
news:11**********************@p79g2000cwp.googlegr oups.com...
>I have a query with criteria that comes from a combo box on a form. I'd
like to set the query up so the user can either limit the criteria to
the selection in the combo box or the user can pull all records. Can't
figure out a way for the query to pull all records. Currently uses the
criteria [forms]![frmreport]![combo10]. I've tried a couple of things
to allow for the option of all records, but without any luck. Any
suggestions?

Jul 5 '06 #2
AP
Another way to skin the cat
Put this in the criteria of the field that is based on the combo box

Like IIf(IsNull([Forms]![test]![Combo0]),"*",[Forms]![test]![Combo0])

AP

Jul 5 '06 #3
Col
This seems to be working fine. Thanks so much!!

AP wrote:
Another way to skin the cat
Put this in the criteria of the field that is based on the combo box

Like IIf(IsNull([Forms]![test]![Combo0]),"*",[Forms]![test]![Combo0])

AP
Jul 5 '06 #4
Actually, this one fails to return the records where the field is Null.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"AP" <me**********@greenixsolutions.comwrote in message
news:11**********************@m79g2000cwm.googlegr oups.com...
Another way to skin the cat
Put this in the criteria of the field that is based on the combo box

Like IIf(IsNull([Forms]![test]![Combo0]),"*",[Forms]![test]![Combo0])

Jul 5 '06 #5
AP
Interesting,
Thanks for pointing that out Allen. I have always used that method on
required fields, so it never bit me.

Nice to know though. Thanks
AP
Allen Browne wrote:
Actually, this one fails to return the records where the field is Null.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"AP" <me**********@greenixsolutions.comwrote in message
news:11**********************@m79g2000cwm.googlegr oups.com...
Another way to skin the cat
Put this in the criteria of the field that is based on the combo box

Like IIf(IsNull([Forms]![test]![Combo0]),"*",[Forms]![test]![Combo0])
Jul 5 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Salad | last post by:
This may occur to you in the future. You want to get the min or max of a field that you set criteria on...maybe for a combo box. Let's say you wanted to get the minimum of all date fields where...
4
by: bhbgroup | last post by:
I have a query on one large table. I only add one condition, i.e. a date (the SQL reads like 'where date > parameterdate'. This query is rather quick if 'parameterdate' is either explicitly...
2
by: Steve | last post by:
Access 97. I have a form where there is an option group with two buttons, and a combo box. The combo box Row Source is a query. The option group has two options a) include a subset of the...
1
by: Giordano | last post by:
I am trying to construct a report menu that will allow the user to select any combination of 3 variables from 3 combo boxes (Select Subject/SelectCategory/Date Range). There are 2 possible options...
3
by: shorti | last post by:
db2 v 8.2 on AIX 5.3 I will try to explain as brief as I can what it is I need. I am building a function that will be called multiple times where I will need to return x amount of records each...
3
by: ericargent | last post by:
Hi I'm using Acces 2003 I have Query where the several parameters for the criteria are supplied from a form. One parameter source is a combo box. What I am trying to do is if: An item is...
3
by: suek | last post by:
I have a table with over 4000 records to search upon, and the users don't like a combo box. So what I have been trying to do for the last twelve hours is do some code to get a text box to search. ...
1
by: Doug | last post by:
What is the simplest way to make a report where only the records where a field matches a certain date are included, and the user first selects that date (from form or popup)? (I can write the SQL...
3
by: Christoph | last post by:
I have an <S access databse and try to select the the customer ID to print a statemet report based on the customer ID but am unable to do so Can anybody help Thank you Christoph Access...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.