Query by Form Yes/No

User avatar
agibsonsw
SilverLounger
Posts: 2403
Joined: 05 Feb 2010, 22:21
Location: London ENGLAND

Query by Form Yes/No

Post by agibsonsw »

Hello. Access 2007.
I'm creating a form with unbound controls, with a button which then opens a form using the unbound data
as search criteria.
I have a Yes/No control on the search form. If it's unchecked (null?) initially I want to show all the records, but
my expression doesn't work. I've tried
IIF(Forms!frmSearch!cbkBonus Is Null,Yes Or No Or Is Null,Forms!frmSearch!cbkBonus)
How can I get this to work? Thanks Andy.
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.

User avatar
HansV
Administrator
Posts: 78542
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Query by Form Yes/No

Post by HansV »

So if cbkBonus is unchecked, you want to display all records. What should happen if cbkBonus is checked?
Best wishes,
Hans

User avatar
agibsonsw
SilverLounger
Posts: 2403
Joined: 05 Feb 2010, 22:21
Location: London ENGLAND

Re: Query by Form Yes/No

Post by agibsonsw »

Currently, if they check or uncheck it I want to show staff who do or do not have a bonus. But when the form is first
opened, if they ignore it I want to show all records. (This may appear slightly illogical?!) Andy.
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.

User avatar
HansV
Administrator
Posts: 78542
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Query by Form Yes/No

Post by HansV »

Set the Triple State property of cbkBonus to Yes; you can then toggle the check box between three instead of two states: Yes, No and undetermined.

Set the condition for the bonus field to

Forms!frmSearch!cbkBonus Or (Forms!frmSearch!cbkBonus Is Null)
Best wishes,
Hans

User avatar
agibsonsw
SilverLounger
Posts: 2403
Joined: 05 Feb 2010, 22:21
Location: London ENGLAND

Re: Query by Form Yes/No

Post by agibsonsw »

Thank you, I'll try that. Andy.
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.