Trying to Hide/Display Fields based on checkbox being selected

B

Ben Pelech

Hello, I am trying to see if I can show/hide about 5 combo boxes based on
whether a check box is displayed. Right now, the code I found so far, only
allows me to Show them if the check box is selected but will not hide them if
it is unselected. Below is the current code

Private Sub Was_Contact_due_to_Error__Click()
Me.Combobox1.Visible = True
Me.ComboBox2.Visible = True
Me.ComboBox3.Visible = True
Me.ComboBox4.Visible = True
Me.ComboBox5.Visible = True
End Sub

I would also like a way to add in the code to add new form that will refresh
these combo boxes on the new form if the previous was selected. It doesnt
seem to completely refresh if there was an error on the previous form and the
check box was selected.

Any help would be greatly appreciated

Thanks
 
M

Marshall Barton

Ben Pelech said:
Hello, I am trying to see if I can show/hide about 5 combo boxes based on
whether a check box is displayed. Right now, the code I found so far, only
allows me to Show them if the check box is selected but will not hide them if
it is unselected. Below is the current code

Private Sub Was_Contact_due_to_Error__Click()
Me.Combobox1.Visible = True
Me.ComboBox2.Visible = True
Me.ComboBox3.Visible = True
Me.ComboBox4.Visible = True
Me.ComboBox5.Visible = True
End Sub

Private Sub Was_Contact_due_to_Error__Click()
Me.Combobox1.Visible = Me.Was_Contact_due_to_Error_
Me.ComboBox2.Visible = Me.Was_Contact_due_to_Error_
Me.ComboBox3.Visible = Me.Was_Contact_due_to_Error_
Me.ComboBox4.Visible = Me.Was_Contact_due_to_Error_
Me.ComboBox5.Visible = Me.Was_Contact_due_to_Error_
End Sub
I would also like a way to add in the code to add new form that will refresh
these combo boxes on the new form if the previous was selected. It doesnt
seem to completely refresh if there was an error on the previous form and the
check box was selected.

I don't understand what you are trying to do here.
 
B

Ben Pelech

I have a database that I have a checkbox that indicates an error is made. I
have 5 combo boxes that i would like to hide and display based on if the
checkbox is checked. For example. There was an error made, the 5 combo
boxes appear that you choose which kind of error it was. But i dont want
them visible if there is no error.

Is this possible?

Thanks
 
M

Marshall Barton

You said that before.

Did you try the code I posted? If you did, what happened?
If you don't try it, why not?
 
B

Ben Pelech

Sorry I was confused. Did not realize what you put in my original post. It
works perfectly for the check/uncheck to hide/unhide the combo boxes. My
only problem now is that when i go to a new form (click add new command
button) the combo boxes appear on the new form instead of refreshing as a
clean entry.

Thanks for all of your help!!!

Marshall Barton said:
You said that before.

Did you try the code I posted? If you did, what happened?
If you don't try it, why not?
--
Marsh
MVP [MS Access]


Ben said:
I have a database that I have a checkbox that indicates an error is made. I
have 5 combo boxes that i would like to hide and display based on if the
checkbox is checked. For example. There was an error made, the 5 combo
boxes appear that you choose which kind of error it was. But i dont want
them visible if there is no error.
 
M

Marshall Barton

Try this in the form's Current event procedure:

If Me.NewRecord Then
Me.Combobox1.Visible = False
Me.ComboBox2.Visible = False
Me.ComboBox3.Visible = False
Me.ComboBox4.Visible = False
Me.ComboBox5.Visible = False
End If
 
B

Ben Pelech

Thank you so much! It works perfectly!!!!!

Marshall Barton said:
Try this in the form's Current event procedure:

If Me.NewRecord Then
Me.Combobox1.Visible = False
Me.ComboBox2.Visible = False
Me.ComboBox3.Visible = False
Me.ComboBox4.Visible = False
Me.ComboBox5.Visible = False
End If
--
Marsh
MVP [MS Access]


Ben said:
Sorry I was confused. Did not realize what you put in my original post. It
works perfectly for the check/uncheck to hide/unhide the combo boxes. My
only problem now is that when i go to a new form (click add new command
button) the combo boxes appear on the new form instead of refreshing as a
clean entry.
 

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