Yes, No, "Both" Query.

andmunn

Registered User.
Local time
Yesterday, 21:49
Joined
Mar 31, 2009
Messages
195
Hi All,

I have a combo box with the values -1 (Yes), and 0 (No) which runs against a query with the field "IsITRelated".

If i select -1 from the combo box, it only brings back results which are IT related. If it is 0, it brings back only results that are not IT related.

Can i "program" something into the combox box such that it displays both yes and no value for a 3rd options in the dropdown?

Andrew.
 
of course you can. If you have it bound to table, change the type to a non-boolean type field, query the box and issue IIF() statements in your query statement, based on what the box value is.

if it's a value list, simply add a value like 'both' to the list in the prop sheet.
 
Hm,

The combox box is definately not bound to any table. However, i tried inputting "both" and get an error stating "The value entered isn't valid for this field".

I also tried inputting "-1 or 0" as the 3rd option, and that isn't working either...

I must be missing something very simple :)

Andrew.
 
If you simply do not include the field in your criteria, you will get all records that have either a 0 or -1.
 
Hi Rick,

Definately doesn't work that way either. My query references the combox box (yes/no) in such a manner:

Field "is ITQuery":
[Forms]![frmInternationalScorecard]![cboxIsITQuery]

It works if the combo box (cboxIsItQuery) has -1, or 0, but if i leave it blank it returns nothing...

Andrew.
 
If you reference the control in a query then you will not be able to do what you are trying to do. You're best bet in this situation would be to create the query dynamically.
 
If you reference the control in a query then you will not be able to do what you are trying to do. You're best bet in this situation would be to create the query dynamically.

Rick was right in this first post, he just forgot to include HOW to do it. dynamically is NOT the way to do this.

try this:
Code:
where [is ITQuery] = [Forms]![frmInternationalScorecard]![cboxIsITQuery] or 

[Forms]![frmInternationalScorecard]![cboxIsITQuery] is null
that will give you exactly what you want, with either 1,0, or ALL. I'm almost 100% sure it works with all data types, boolean or otherwise.

there are also numerous FAQ pages on this forum about this same concept.
 
Hi TheNet!

That worked perfectly. FYI - i did attempt searching this board (Even through google), and it couldn't find what i was looking for.

Andrew.
 
This is how I solve that problem.

This example shows a Combo Box and an Option Group that update each other, as well as a subform.
 

Attachments

Last edited:

Users who are viewing this thread

Back
Top Bottom