Working with Checkboxes in Queries

G

Guest

Hello,

I have a table that uses yes/no checkboxes. I'm now at a point where I need
to use the data in a query, especially in IIF() statements. However, I don't
know how this is done with checkboxes. It returns an error if I write
IIF([field]="Yes",1,0) .

How do I reference a checked checkbox in an IIF() statement?

Thanks for your help,
Jx2C
 
F

fredg

Hello,

I have a table that uses yes/no checkboxes. I'm now at a point where I need
to use the data in a query, especially in IIF() statements. However, I don't
know how this is done with checkboxes. It returns an error if I write
IIF([field]="Yes",1,0) .

How do I reference a checked checkbox in an IIF() statement?

Thanks for your help,
Jx2C

IIF([field]=-1,1,0)
or
IIF([field]=Yes,1,0)
or
IIF([field]=True,1,0)

Note: there are NO quotes around Yes or True.

Are you trying to count how many Yes boxes there are in a field?
=ABS(Sum([CheckBox]))
 
M

Michel Walsh

Hi,


A check box is only a "format", like a $ is to a currency. The field is
Boolean, so


iif( fieldName, 1, 0 )



Note that a Boolean false (or 'no', or 'off') is 0, and true (or 'yes', or
'on' ) is anything else (but not null). Also note that a no or a yes is
language dependant, and so, you can get something else in Spanish, in
French, etc. while 0 is 0 is 0.




Hoping it may help,
Vanderghast, Access MVP
 
M

Marshall Barton

Jx2C said:
I have a table that uses yes/no checkboxes. I'm now at a point where I need
to use the data in a query, especially in IIF() statements. However, I don't
know how this is done with checkboxes. It returns an error if I write
IIF([field]="Yes",1,0) .


IIF([field]=True,1,0)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top