Visual basic help

Associate
Joined
21 Jun 2004
Posts
1,635
Hi, Im building a database form for a hospital audit and for part of that I wanted to have users click a box to open extra boxes to put in further information. This is the first database/form system I've used and first time I've used Access & VB so go easy on me :)

At the moment I can get the 2 text boxes to remain hidden until a command button or checkbox is clicked. I was wondering how to code so that if the check box is unticked the options would become hidden once again. I've been playing around with the IF command trying to use the value of the check box as equal to true or false, but with no luck. Is there an easy command that I`m missing or is it a limitation of VB?

My best effort at present is:

Private Sub Check159_Click()
If Me.Check159 = True Then
Me.Combo154.Visible = True
Me.Text151.Visible = True
Else
If Me.Check159 = False Then
Me.Combo154.Visible = False
Me.Text151.Visible = False
End If
End Sub

Which doesnt work in the slightest and has lost the initial reveal that I had previously. Any help would be most appreciated!
Thanks
 
Associate
OP
Joined
21 Jun 2004
Posts
1,635
Thanks, I`m nearly there now with:


Private Sub Form_Load()
Check159.Value = 1
End Sub

Private Sub Check159_Click()
If Check159.Value = 0 Then
Text151.Visible = True
Combo154.Visible = True
Else
Text151.Visible = False
Combo154.Visible = False
End If
End Sub

I`m starting with the 2 objects set to visible=false in their properties profile. At the moment it works perfectly except for the fact that the box is ticked when the boxes are hidden and unticked when they are visible. How do I swap the appearance of the box? I've tried changing the starting value, but that seems to just break the code.

Thanks for any help
 
Back
Top Bottom