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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hiding Labels and Boxes based on Checkbox 1

Status
Not open for further replies.

MagnumVP

IS-IT--Management
Jul 9, 2002
109
US
I want a label (Label86) and a ComboBox (ComboBox86) to hide when the checkbox is checked.

In the VBA Code I have tried;

If Checkbox.Enabled = True Then
Label86.hide()
Comboxbox86.hide()
Else
Label86.show()
Comboxbox86.show()
End If


I've also tried

If CheckBox.Enabled = True Then
Label86.IsVisible = False
ComboBox86.IsVisible = False
Else
Label86.IsVisible = True
ComboBox86.IsVisible = True
End If


What else can I try?
 
How are ya MagnumVP . . . . .

Try This:
Code:
[blue]   If Checkbox.Enabled Then
           Me!Label86.Visible = False
           Me!Comboxbox86.Visible = False
   Else
           Me!Label86.Visible = true
           Me!Comboxbox86.Visible = true
   End If[/blue]

Calvin.gif
See Ya! . . . . . .
 
Hi

if you want it to happen when the check box is checked, then in the after update event of the checkbox control

Label86.Visible = CheckBox
ComboBox86.Visible = CheckBox

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
I want a label (Label86) and a ComboBox (ComboBox86) to hide when the checkbox is checked
In the AfterUpdate event procedure of the checkbox:
Label86.Visible = Not [name of CheckBox]
ComboBox86.Visible = Label86.Visible

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Ok so far so good. I'm almost there.

I've added the following to the "Form_Open" so the boxes will be hidden at first;

Me!Label86.Visible = False
Me!Comboxbox86.Visible = False


I'm using it under the After Update portion;

If Checkbox.Enabled = True Then
Me!Label86.Visible = True
Me!Comboxbox86.Visible = True
Else
Me!Label86.Visible = False
Me!Comboxbox86.Visible = False
End If


The Form opens and the boxes are hidden. When you check the checkbox, the objects appear as they are suppose to. The only problem is that if the UNCHECK the box, they won't disappear.

Thoughts?
 
Ok...figured it out.

Here is the VBA Code.

First you need to place this code so it processed the information when the form opens.


Private Sub Form_Open(Cancel As Integer)
If Me.CheckBox.Value = False Then
Me!Label86.Visible = False
Me!CheckBox86.Visible = False
Else
Me!Label86.Visible = True
Me!CheckBox86.Visible = True
End If
End Sub


Then you need to place the following code in the "After_Update" of the Checkbox.

Private Sub Checkbox_AfterUpdate()
If Me.CheckBox.Value = True Then
Me!Label86.Visible = True
Me!Checkbox86.Visible = True
Else
Me!Label86.Visible = False
Me!Checkbox.Visible = False
End If
End Sub


The problem originally was "Me.Checkbox.Enable = True" when it should have been "Me.Checkbox.Value = True"

Thank you for EVERYONE's help.

Greatly appreciated.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top