Make fields visible and invisible on check box

M

mel

When I open my form there are two fields and a calendar button that I want to
be hidden. When check box is clicked I want these fields and the button to
become visible. I already tried a few things, on click, on open
If Field = "Yes" Then
Field.Visible = True
Else
Field.Visible = False
End If
The fields I specify disappear but don't reappear when I check the box.
 
B

Brian

This might be simpler:

chkBox_Click() 'click event of a check box
txt1.Visible = chkBox 'a text box on the form
cbo1.Visible = chkBox 'a combo box on the form
btn1.Visible = chkBox 'a button on the form
End Sub

When checking the box, you are setting its value to True, when unchecking
it, you set it to False, so each of these applies to the .Visible property of
the other controls.
 
M

mel

Hi Brian,
That works great!...except how do I make the boxes be hidden when I open a
new record. When I open a new record the fields are there and I have to check
and then un-check the box to make them disappear.
 
B

Brian

Something like this. It makes them invisible on new records but visible on
exisitng records.

Private Sub Form_Current()
If Form.NewRecord Then
chkBox = False 'unchecks the box
Else
chkBox = True 'checks the box
End If
chBox_Click 'runs the code from that event, which sets the Visible
properties
End Sub
 

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