472,953 Members | 1,824 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,953 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 1770
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: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

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.