09-30-2001, 07:53 AM
I have one form that has around 100 check boxes that the user can chose from and I would like to collect this information on another form without alot of hassles can anyone aid me in this.
Thank you in advance
09-30-2001, 08:09 AM
If you want to access the controls on another form, the you just need to add the form name infront of the control. Thoe following code could be placed in any form or code module:
<pre>Form1.Check1.Value = 1</pre>
Even if this is done from Form2, it will still affect Form1. If you find that you are doing a lot of stuff dealing with the other form, then I would suggest using With:
.Check1.Value = 1
.Check2.Value = 0
.Caption = "Form 1"
.Label1.Caption = "Some text"
.Label2.BackColor = vbRed
09-30-2001, 08:28 AM
so if my code looks like this (showing the results in a text box on the orignal form)
Private Sub Check_2attack_Click()
If Check_2attack.Value = Checked Then
Text1.Text = Text1 + (";2_attack")
what would I need to change to have it show the results on the second form
would it be :
.check_2attack.value = checked
.Text1.Text = Text1 + (";2_attack")
09-30-2001, 08:37 AM
If check_2attack and Text1 are objects on Form1, yes. This will not, however, show ANYTHING on form2.
09-30-2001, 08:40 AM
so how would I get it to show on form 2
09-30-2001, 08:45 AM
Right, lets suppose you have two forms, Form1 and Form2, and you want the value of a textbox to change on Form2 depending on the value of a checkbox on Form1, by clicking a button on Form1. You would add this code to Form1:
<pre>Private Sub Command1_Click()
And this code in the code window of Form2:
<pre>Private Sub Form_Load()
If Form1.Check1.Value = 1 Then
Text1.Text = "The box on form1 is checked"
Text1.Text = "The box on form1 in unchecked"
This is how you access controls from other forms.
09-30-2001, 08:56 AM
thank you kind sir that is exactly what I was looking for