how do i use checkboxes to show or hide other controls on a form?

G

Guest

when form loads, I need to see only two checkboxes. When I check the first
one, two textboxes needs to show. When I move to the next record, I want the
two checkboxes to be displayed by themselves again.

Now, I have 200 records in the table. If the first Checkbox is checked,
display the two textboxes, if the second checkbox is checked, don't display
the two textboxes.

How can I do this for all the records in the table when I browse the recs on
the form.

thank you.

Radu
 
T

tina

assuming that the two checkboxes on the form are unbound, try the following:

in the form's Current event procedure, add the following, as

Me!FirstTextboxName.Visible = False
Me!SecondTextboxName.Visible = False

actually, you don't need 2 checkboxes to show/hide the textboxes - you only
need one. since a checkbox represents True/False, On/Off, Yes/No, you can
checkmark a single checkbox to show the textboxes, and un-check the checkbox
to hide them again. add the following code to the checkbox control's
AfterUpdate event procedure, as

Me!FirstTextboxName.Visible = Me!CheckboxName
Me!SecondTextboxName.Visible = Me!CheckboxName

hth
 
P

PC Datasheet

First, you only need one checkbox! In design view, set the visible property
of both textboxes to No. Put the following code in the AfterUpdate event of
the checkbox:
If Me!NameOfCheckbox = True
Me!NameOfTextbox1.Visible = True
Me!NameOfTextbox2.Visible = True
Else
Me!NameOfTextbox1.Visible = False
Me!NameOfTextbox2.Visible = False
End If

Put the following code in the OnCurrent event of the form:
Me!NameOfTextbox1.Visible = False
Me!NameOfTextbox2.Visible = False
 
D

Douglas J. Steele

Or simply

Me!NameOfTextbox1.Visible = Me!NameOfCheckbox
Me!NameOfTextbox2.Visible = Me!NameOfCheckbox
 
P

PC Datasheet

Doug,

I actually like to use this code but I have found dabblers in Access have a
very hard time understanding how it works!

Steve
PC Datasheet
 

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