Input Yes or No not 0 or -1

rchmndf

New member
Local time
Today, 15:29
Joined
Nov 21, 2008
Messages
4
I am inputing records through a form that has a check box to identify members. In the table the check box shows checked for members and no check for non-members.

I want to run a single query that will pull members or non-members based on input from the user. In the query now I have the table and field listed with the criteria of [Member: Yes or No] to prompt the user for input.

I can input 0 or -1 and get the correct result but I want the user to be able to input "Yes" or "No" (not 0 or -1).

Any suggestions?
 
You could create a calculated field in your query with the following calculation:
IIf([myYNfield]=True,"Yes","No")

Then just put your parameter against this field instead of the boolean field.

hth
Chris
 
Can I just suggest that you flip that logic around?
Calculate the user's criteria input into a boolean expression comparable against the boolean field.

So rather than
WHERE IIf([myYNfield]=True,"Yes","No") = Forms!frmCriteria!txtYesNo

have
WHERE [myYNfield] = IIF(Forms!frmCriteria!txtYesNo = "No", 0, -1)
which, in Jet, Access or VBA is also
WHERE [myYNfield] = IIF(Forms!frmCriteria!txtYesNo = "No", False, True)
and you can even have
WHERE [myYNfield] = IIF(Forms!frmCriteria!txtYesNo = "No", No, Yes)

(Notice that they are Not strings but literal values that are accepted as boolean results - it's a Jet only hack :-s)

Switching the calculation around to the criteria lets the db engine perform better (even though a boolean field isn't going to use index optimisation :-)
It's a good habit to get in to anyway.

Cheers.
 

Users who are viewing this thread

Back
Top Bottom