Avatar of ttist25
ttist25
 asked on

Reference a checkbox value in Access query

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.
Microsoft Access

Avatar of undefined
Last Comment
Dale Fye

8/22/2022 - Mon
Minh Võ Công

you try
iif(MyTable.MyCheckbox=-1,
"Do this.",
"Don't do that.")
AS MyTextBox,
Minh Võ Công

DatabaseMX (Joe Anderson - Former Microsoft Access MVP)

How about this

If Me.MyCheckbox= True Then
   ' do this
Else
  ' do that
End If
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
Richard Daneke

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.")
ASKER CERTIFIED SOLUTION
Dale Fye

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question