Reference a checkbox value in Access query

ttist25
ttist25 used Ask the Experts™
on
Hey there,

I'm trying to set the value of a text box on my access report based on the value of a checkbox.

I'm using this:

iif(MyTable.MyCheckbox="-1",
"Do this.",
"Don't do that.")
AS MyTextBox,

but I get "#Error" in MyTextBox on the report when I run it.

I've tried using ="Yes" and ="True" etc. but I get the same results.  

Any ideas what I'm doing wrong?  

Thanks in advance for any help.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
you try
iif(MyTable.MyCheckbox=-1,
"Do this.",
"Don't do that.")
AS MyTextBox,
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Application Developer
Top Expert 2007

Commented:
How about this

If Me.MyCheckbox= True Then
   ' do this
Else
  ' do that
End If
The control itself tests as true or false.
iif(MyTable.MyCheckbox="-1",
"Do this.",
"Don't do that.")
AS MyTextBox,

could be changed to
iif(Me.MyCheckbox, MyTextBox ="Do this.",MyTextBox ="Don't do that.")
Owner, Dev-Soln LLC
Most Valuable Expert 2014
Top Expert 2010
Commented:
if this is in a query, try:

myTextBox: iif(myCheckbox, "Do This", "Don't do that!")

in the SQL it would look like:

Select field1, field2, iif(myCheckbox, "Do This", "Don't do that!") as myTextBox
FROM yourTable

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial