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

CheckBox Help 1

Status
Not open for further replies.

WildGun

Technical User
Jan 13, 2005
15
US
Hi

First please understand I am new to VB and I am trying to learn, I have 12 CheckBoxes on an option form that toggle TextBoxes on and off if applicable, insert text, and cause frames to be visible on other forms. The problem is that using the code listed below the first check box works fine, as expected however the second CheckBox when checked also does what it is suppose to but when unchecked it remains as if it were still checked, and the same with the remaining boxes. they will all activate when checked but they will not change when unchecked.

If (CheckBox1.Value = Checked) Then
TextBox1.Visible = True 'enables the site name field
TextBox1.Text = "Site 1" 'adds the text Site 1 to the text box
CheckBox2.Enabled = True 'enables the next field
frmUser1!frame_ch1.Visible = True 'enables the main user module
ElseIf (CheckBox1.Value = Unchecked) Then
TextBox1.Visible = False
CheckBox2.Enabled = False
frmUser1!frame_ch1.Visible = False
End If

I used generic name to help out, please halp if you can and please recommend and good books I should purchase.

Thanks
Randy
 
Maybe u can try this one, i am trying to create only 3 check box & 1 text box.

step 1
create 1 checkbox, and u have to make it in array (click on the checkbox1, then ctrl+c (copy), then ctrl+v (paste), if they ask "make control array?", answer to click "Yes")
u can make control array, as much as u want, ok
step 2
insert this code into 1 of the check box, from the 1st time u create control array with it, the code is....

Private Sub Check1_Click(Index As Integer)
Select Case Check1(Index)
Case Check1(0)
Text1.Text = "Site 1"
Check1(1).Value = 0
Check1(2).Value = 0
Case Check1(1)
Text1.Text = "Site 1"
Check1(0).Value = 0
Check1(2).Value = 0
Case Check1(2)
Text1.Text = "Site 1"
Check1(0).Value = 0
Check1(1).Value = 0
End Select
End Sub


hope this can help u

Best regards,

Y7025

 
Oops, change it a little bit.....
Maybe u can try this one, i am trying to create only 3 check box and 1 text box.

step 1
create 1 checkbox, and u have to make it in array (click on the checkbox1, then ctrl+c (copy), then ctrl+v (paste), if they ask "make control array?", answer to click "Yes")
u can make control array, as much as u want, ok
step 2
insert this code into 1 of the check box, from the 1st time u create control array with it, the code is....

Private Sub Check1_Click(Index As Integer)
Select Case Check1(Index)
Case Check1(0)
Text1.Text = "Site 1"
Check1(1).Value = 0
Check1(2).Value = 0
Case Check1(1)
Text1.Text = "Site 2" ' this one i revised
Check1(0).Value = 0
Check1(2).Value = 0
Case Check1(2)
Text1.Text = "Site 3" ' this one i revised
Check1(0).Value = 0
Check1(1).Value = 0
End Select
End Sub

hope this can help u

Best regards,

Y7025
 
Wildgun,

Try;

TextBox1.Visible = (CheckBox1.Value = 1)
TextBox1.Text = "Site 1"
CheckBox2.Enabled = (CheckBox1.Value = 1)
frmUser1!frame_ch1.Visible = (CheckBox1.Value = 1)

regards Hugh
 
Well I am still having trouble, I have tried Hugh's solution however when I run it I receive an error on the line that read as follows; "CheckBox2.Enabled = (CheckBox1.Value = 1)" also I have found that if I do not use CheckBox1 and use CheckBox2 through CheckBox12 they work perfectly, the problem only occurs when CheckBox1 is checked. To make it a little clearer, when I check CheckBox1 it works fine and toggles on and off, when I check CheckBox2 through CHeckBox12 they toggle on but will never toggle off until CheckBox1 is unchecked.

Any ideas?

Thanks

Randy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top