Make field appear when checkbox is ticked

hello all

firstly i'll admit know next to nothing when it comes to Access, i've just got my head around setting up a relational database so i am getting there slowly, but if your suggestions involve using code (i imagine it would) could you please tell me exactly where to put it ie. in the expression builder, or in a macro or whatever.

as the title suggests i would like a field to appear in form view if a checkbox is ticked. i would like to use this twice in my form - the first time the field that appears is just going to be a simple text field, but the second time i want to use it the field that appears is going to lookup data from another table - i don't know if this makes a difference to the code.

Also if the box is then unticked i would like the fields to disappear - i don't mind if the data that was entered in the field when the box was ticked is retained or not


is there anywhere online that lists the expressions and how to use them? or even a semi-advanced user manual for Access 2010 (or 2007)? i've had a quick google but can't find anything

thanks in advance for your suggestions - i know it will be an easy 500 points for the Access wizards out there
LVL 13
mrroonieAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mrroonieAuthor Commented:
Sorry - forgot to mention - using Access 2010
conagramanCommented:
the way you make things appear disappear in access is just using the visible property of an object.
such as
visible = true
or
visible = false

check boxes are quite easy as well. if they are checked their value is = to true or -1. if they are not check the value is = false or 0

there are different ways to look values up in a table you can use a sql query or a handy built in function in access is the DLookup function. here is a sample database which you can use for reference.

checkbox.accdb

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rgn2121Commented:
So it sounds like you want to have 2 checkboxes and 2 other controls on your form.  One being a textbox and the other possibly a combobox depending on your needs.

With the checkbox, when it gets clicked you want the textbox to display.  So, look at the properties of the checkbox and go to the events and you want to go to the code view for the after update event.

In that event type something like....
 if me.checkbox1 = true then
       me.textbox1.visible=true
else
       me.textbox1.visible=false
end if

same idea for the other one as well...only depending on what control you are using will affect any additonaly code.
             
Protecting & Securing Your Critical Data

Considering 93 percent of companies file for bankruptcy within 12 months of a disaster that blocked access to their data for 10 days or more, planning for the worst is just smart business. Learn how Acronis Backup integrates security at every stage

conagramanCommented:
to view the code :

view the form in design view. select the checkbox or the button then look in the event tab of the properties menu
conagramanCommented:
also here is a link of Access vba functions. looks pretty complete. hope this helps
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
I would also caution you against making UI objects appear and disappear unless you have a very good reason to do so. UI studies have long shown that users do NOT like this, and can get quite confused and frustrated with disappearing textboxes.

About the only reason you would entirely hide a textbox would be cases where you're hiding sensitive information. For example, in an Employee app, you might want the Managers group to be able to view salary information, but of course standard Users should NOT be able to view those sorts of things. In cases like this, you would have a valid reason for showing/hiding UI objects.
mrroonieAuthor Commented:
thanks conagraman & rgn2121 - that code works a treat.

LSMConsulting - there are only 2 people that will be using this database, and this is what they want, but thanks for the pointer anyway
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.