IIF statement question

A

ArielZusya

I've got a form that, among other things, has a checkbox ("chkExpert")
associated with a Yes/No field in a table, and an unbound textbox
("txtExpert"). I'd like to have the text displayed in the unbound txtExpert
change based on whether or not chkExpert is checked. I thought all I needed
to do is set the recordsource for txtExpert to an IIF statement. Namely:

=IIF([chkExpert]=-1,"Yes","No")

but for some reason, doing that gives me the #Name? Error. It's been a while
since I last did any Access coding/design. Am I forgetting something? Am I
missing a step? Thanks!
 
K

Klatuu

Make the Control Source property of the text box
=[chkExpert]

And set it's Format Property to Yes/No
 
A

ArielZusya

Alright... That was a really easy and elegant solution. Thanks! But what if I
want it to say something other than Yes and No (like "Not an expert" or
"Expert")? Am I doing something wrong with the IIF? Is IIF not the way to do
this? Is there a way to do this? thanks for your help!

Klatuu said:
Make the Control Source property of the text box
=[chkExpert]

And set it's Format Property to Yes/No
--
Dave Hargis, Microsoft Access MVP


ArielZusya said:
I've got a form that, among other things, has a checkbox ("chkExpert")
associated with a Yes/No field in a table, and an unbound textbox
("txtExpert"). I'd like to have the text displayed in the unbound txtExpert
change based on whether or not chkExpert is checked. I thought all I needed
to do is set the recordsource for txtExpert to an IIF statement. Namely:

=IIF([chkExpert]=-1,"Yes","No")

but for some reason, doing that gives me the #Name? Error. It's been a while
since I last did any Access coding/design. Am I forgetting something? Am I
missing a step? Thanks!
 
K

Klatuu

Not sure why it didn't work, I just set up a test case and it worked for me.



--
Dave Hargis, Microsoft Access MVP


ArielZusya said:
Alright... That was a really easy and elegant solution. Thanks! But what if I
want it to say something other than Yes and No (like "Not an expert" or
"Expert")? Am I doing something wrong with the IIF? Is IIF not the way to do
this? Is there a way to do this? thanks for your help!

Klatuu said:
Make the Control Source property of the text box
=[chkExpert]

And set it's Format Property to Yes/No
--
Dave Hargis, Microsoft Access MVP


ArielZusya said:
I've got a form that, among other things, has a checkbox ("chkExpert")
associated with a Yes/No field in a table, and an unbound textbox
("txtExpert"). I'd like to have the text displayed in the unbound txtExpert
change based on whether or not chkExpert is checked. I thought all I needed
to do is set the recordsource for txtExpert to an IIF statement. Namely:

=IIF([chkExpert]=-1,"Yes","No")

but for some reason, doing that gives me the #Name? Error. It's been a while
since I last did any Access coding/design. Am I forgetting something? Am I
missing a step? Thanks!
 
A

ArielZusya

Ug... not sure what was wrong. I closed the form on which I had those
elements and create a brand new form, identical to the previous form in every
way (though it was named frmTest instead of the frmListAttendees I was
working with before). Suddenly it worked. This isn't the first time this has
happened to me in Access. I suppose I should have had more faith in my memory
and less in the program, and just tried starting over building that form. Oh
well. Thanks for your help and for the verification!

Klatuu said:
Not sure why it didn't work, I just set up a test case and it worked for me.



--
Dave Hargis, Microsoft Access MVP


ArielZusya said:
Alright... That was a really easy and elegant solution. Thanks! But what if I
want it to say something other than Yes and No (like "Not an expert" or
"Expert")? Am I doing something wrong with the IIF? Is IIF not the way to do
this? Is there a way to do this? thanks for your help!

Klatuu said:
Make the Control Source property of the text box
=[chkExpert]

And set it's Format Property to Yes/No
--
Dave Hargis, Microsoft Access MVP


:

I've got a form that, among other things, has a checkbox ("chkExpert")
associated with a Yes/No field in a table, and an unbound textbox
("txtExpert"). I'd like to have the text displayed in the unbound txtExpert
change based on whether or not chkExpert is checked. I thought all I needed
to do is set the recordsource for txtExpert to an IIF statement. Namely:

=IIF([chkExpert]=-1,"Yes","No")

but for some reason, doing that gives me the #Name? Error. It's been a while
since I last did any Access coding/design. Am I forgetting something? Am I
missing a step? Thanks!
 

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

Top