Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Question with iff and yes/no format 1

Status
Not open for further replies.

sorensok

Programmer
Oct 29, 2002
36
US
I have a bit of code that I have used before:

=IIf([data1] Is Null,"",[Check1])

Check1 is defined with datatype Yes/No. If I use "Check1" alone in a form, it appears as a checkbox. When I use the statement above, Check1 appears as text (either "yes" or "no") on my form. How can I change this statement so check1 will appear as a checkbox?

Thank you!

Fred
 
I am not positive on what you are asking, but you might check your table design and see if the format for the boolean works better as an "on/OFF" or a "True/False".
By default boolean values appear as check boxes on forms, unless I am mistaken. What does the statement listed do? Is it supposed to alter the value of the control, create it, or what?

-chris
 
The statement listed above does this:

if data1 is blank, do not display check1(which is a checkbox)

if data1 is not blank, display check1

Instead of displaying a checkbox (which I WANT), it just desplays the value.

I've tried On/off, True/False, and Yes/No. When I use JUST check1 in my form it appears as a checkbox, but when I use it in the statement above, it just gives me a YES or a NO in text.

Any ideas on what to change?

Thank you,

Fred
 
try me.Check1.Visible=iif([data1 is null,false,true)
 
or
me.check1.visible = not(isnull([data1])) =============
Jeremy Wallace
Designing, Developing, and Deploying Access Databases Since 1995

Take a look at the Developers' section of the site for some helpful fundamentals.
 
Jeremy,

Your code works, though I'm not quite sure where to put it. If I put it in the Form: on open section, it only performs the code once, either making them all visible or all not visible. If I put it in the check1-on enter or before update section, it only tries to hide it once you actually click on it.

I used to put my example from above directly in the control source.

Thank you for the help!

Fred
 
Put it in the on open of the form and the afterUpdate of the control that holds data1. Then it will fire at all the times you need it to.

Jeremy =============
Jeremy Wallace
Designing, Developing, and Deploying Access Databases Since 1995

Take a look at the Developers' section of the site for some helpful fundamentals.
 
Jeremy,

I put it in the afterUpdate of the control that holds data1(along with OnOpen of form). It's still not quite right. I have a form that reads data from a table. On this form, for the few lines that have no data, I want no checkbox. When I put the code in the afterUpdate of the control that holds data1, nothing happens unless I change or update this data. I don't plan on changing or updating this data. Also, when I do change it, ALL the checkboxes are either visible or non-visible, not just that rows.

I hope this makes sense. I appreciate all of the help! I've tried a few different things, and still can't quite get it.

Thanks again!!!

Fred
 
I am going to assume that you are talking about a continuous form.....that is one of the downlfalls of a cintinuous form...the solution, if you are using Access 2K or better, is conditional formatting.....That is where you want to put your code.... Only two things are infinite, the universe and human stupidity, and I'm not sure about the former. (Albert Einstein)

Robert L. Johnson III, MCP, Network+, A+
Access Developer/Programmer
robert.l.johnson.iii@citigroup.com
 
I think Robert and I are going around agree with each other today. Yeah, check into conditional formatting to do that kind of thing.

Jeremy =============
Jeremy Wallace
Designing, Developing, and Deploying Access Databases Since 1995

Take a look at the Developers' section of the site for some helpful fundamentals.
 
Jeremy,

hahahahahahahahahhahahahahahaha.....I Agree!

:) Only two things are infinite, the universe and human stupidity, and I'm not sure about the former. (Albert Einstein)

Robert L. Johnson III, MCP, Network+, A+
Access Developer/Programmer
robert.l.johnson.iii@citigroup.com
 
Can you do conditional formatting with check boxes? I don't seem to be able to. I'm using Access 2002.

Very sorry about the confusion,

Fred
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top