Checkbox check uncheck nased on field value

karthikcoep

Registered User.
Local time
Today, 20:18
Joined
Mar 4, 2009
Messages
40
Checkbox check uncheck based on field value

I have a checkbox, which I use in a report.
The controlsource of the checkbox is an expresssion field in a query.
This expression field has value 1 or 0.
I want the checkbox to be checked when this field's value is 1 and to be unchecked when it is zero.
How is this to be done.
 
Last edited:
Change your field to boolean and use TRUE or FALSE unless you will get confused. Check boxes return -1 for checked (or TRUE in boolean terms), 0 for unchecked (or FALSE).
 
However, if you still want to go ahead with your 1's and 0's do this:

IIF([Field] = 1, TRUE, FALSE)
 
How do you change an expression field to boolean.
The expression field is
Expression:IIF("Table1.Field2 = "abc",1,0)
How do I set this expression field type to boolean

TRUE OR FALSE will also do, because I just want the checkbox field to be checked/ unchecked based on a certain field value.
 
I was referring to the data type of your field.

See previous post for syntax. Hmmm... not sure why you're using "abc" as the criteria?
 
For data type of fields of a table, i can go to table design and change the field type to boolean, but in case of an expression in a query there is no way to change an expression field to booleAN.
 
In the check box's Control Source property like this:

=IIF([FieldName] = 1, TRUE, FALSE)

Obviously change FieldName to the name of the field.

Like I said previously, if this is a new database, change your field to boolean. If you can handle it better with boolean I see no reason why you would always want to type the above in a query or control source.
 

Users who are viewing this thread

Back
Top Bottom