Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using form radio button value as query criteria??

Status
Not open for further replies.

sjh

Programmer
Oct 29, 2001
263
US
Hi,
In my form, I have an option group with two radio buttons like this:
OptionFrame
- rdoDetail (option value = 1)
- rdoSummary (option value = 2)
I want to use the selected radio button values in my query criteria, but it doesn't retrieve the data correctly.

detail and summary are boolean type columns

Code:
SELECT * FROM myTable
WHERE detail = IIf([Forms]![myForm]![OptionFrame]=1,True,False))
AND summary  = IIf([Forms]![myForm]![OptionFrame]=1,False,True))

What am I doing wrong? Please help!

Thank you in advance,
SJH
 
Please confirm, you have two fields 'detail' and 'summary' and if one is true then the other is false. That's the only way this query will work. I can't see anything wrong with your syntax, so I would check the data.
 
OK. I didn't have "=" in front of IIF statement in my Query Design view.

I have a related question, though.
If the 'detail' and 'summary' are not mutually exclusive, then how can I translate this into the query criteria?

For example, if rdoDetail is selected, then I only want to
query by
Code:
detail = IIf([Forms]![myForm]![OptionFrame]=1,True,False)) criteria

and not

Code:
summary  = IIf([Forms]![myForm]![OptionFrame]=1,False,True))

I don't care if 'summary' is False or True.


Do I need to create a separate query for this?

Thank you,
SJH
 
You may try this:
SELECT * FROM myTable
WHERE (detail = ([Forms]![myForm]![OptionFrame]=1)
OR summary = ([Forms]![myForm]![OptionFrame]=2))

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top