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

Query filtered by Option Group - how to Show All?

Hi,

I'm running Access 2010 and have a form with an option group that people can click to filter a query (which displays in a list box) with "Accepted", "Declined" or "Show All".

It works great if I choose the Accepted option (value of 1) or the Declined option (value of 4), but I'm having trouble making the Show All option work (value of 99) - it doesn't display any results. Can you help me? The criteria that I'm using for the field in my query is:

IIf([Forms]![Main_form]![Filter_grp]<99,[Forms]![Main_form]![Filter_grp])

Thanks!
May 16 '12 #1

✓ answered by Rabbit

Please use code tags when posting code.

You should be doing something like this:
Expand|Select|Wrap|Line Numbers
  1. SELECT *
  2. FROM someTable
  3. WHERE someField = IIf(someParameter <> allValue, someParameter, someField)
Return the field value in the false parameter. That way it will always be true, barring any null values. If you have nulls, you will need to Nz() your field.

4 4704
Rabbit
12,516 Expert Mod 8TB
Where's the false parameter of the iif function? That by itself shouldn't work, it should error out.
May 16 '12 #2
Well, I don't have one. :) I'd also tried this:

Expand|Select|Wrap|Line Numbers
  1. IIf([Forms]![Main_form]![Filter_grp]<>99,[Forms]![Main_form]![Filter_grp],(1 Or 2 Or 3 Or 4 Or 5))
But that doesn't work, either. It works great if I only have 1 value for the false part (eg, 1), but I'm not able to put in multiple values with the "or" operator. Is there a better way to do this?

This is the SQL, if that helps:
Expand|Select|Wrap|Line Numbers
  1. SELECT DISTINCT Sessions.ID, Sessions.CFPTitle, Sessions.Organization, Sessions.CFPac, Sessions.CFPfocus, Review.Status, Events.AC
  2. FROM (Sessions INNER JOIN Events ON Sessions.Event = Events.AC) LEFT JOIN (Review LEFT JOIN Status ON Review.Status = Status.StatusID) ON Sessions.ID = Review.Session_ID
  3. WHERE (((Review.Status)=IIf([Forms]![Main_form]![Filter_grp]<>99,[Forms]![Main_form]![Filter_grp],((Review.Status)=1 Or (Review.Status)=2 Or (Review.Status)=3 Or (Review.Status)=4 Or (Review.Status)=5))) AND ((Review.User)=GetUserName()))
  4. ORDER BY Sessions.Organization;
May 16 '12 #3
Rabbit
12,516 Expert Mod 8TB
Please use code tags when posting code.

You should be doing something like this:
Expand|Select|Wrap|Line Numbers
  1. SELECT *
  2. FROM someTable
  3. WHERE someField = IIf(someParameter <> allValue, someParameter, someField)
Return the field value in the false parameter. That way it will always be true, barring any null values. If you have nulls, you will need to Nz() your field.
May 16 '12 #4
That works perfectly! Thank you SO much!!
May 16 '12 #5

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

Similar topics

19
by: What-a-Tool | last post by:
I have a school project (ASP) in which I have to call three different ASP pages from three different and identical (except for the form "action", obviously) HTM pages. This I have no problem with....
1
by: Gazchurchend | last post by:
I get straight to the point... I need to select an item in an option group when a form loads. Its a PHP form which will have a value sent in when the form loads. This value is assigned to a...
7
by: Shyguy | last post by:
I have an option group with about 30 options. I would like to have the Option Labels get their text from a table. Is this possible, and if so how? Also, is it possible to embad a font into a...
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...
2
by: andy.mcvicker | last post by:
Hi Gang I used the Option Group wizard to create a group of radio buttons on a form. It created it with three options and it looks fine. However when I run the form the first option is checked...
4
by: JHite | last post by:
I am using Access 2003 on Windows XP. This is a simple database that contains “tblStaffers” containing names of the office staffers, “tblProjects” containing names of the office projects, and...
2
by: sara | last post by:
Hi I'm having a very strange problem and need HELP!! I have a form for the user to choose a report (radio button in an option group) and parameters (Dates, Season). Click the option button,...
1
tuxalot
by: tuxalot | last post by:
I've copied the option group from my form, and pasted it into the report which seems to work fine. Now, I wish to total the option items in the report. So I have a query that grabs records within a...
5
by: hbaf208 | last post by:
I have an option group (TimeFrameOption) with three options: All, Last 6 months, and Last 12 Months. When an option is selected, I want to query dates in a listbox (CallReport) to display all dates...
11
tuxalot
by: tuxalot | last post by:
Another quick question for ya... Here's my button code, and I want to see if I can do something different so I don't have to repeat the same code for each of my 14 buttons in my option group: ...
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: 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
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
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,...

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.