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!

Refer to control on another form

Status
Not open for further replies.

be17

Technical User
Feb 7, 2001
26
US
I have a program created with about 5 different forms. At one point in one of the forms, I want to have a statement stating that If a checkbox on that form is checked, AND a certain checkbox on the previous form was checked, Then it will prompt the user for information. However, I am new to programming and I am stuck on how to refer to the checkbox on the previous form. I can have some code something like this:

If chkMedical.Value = True

but what kind of code do I write if I want to say that Both chkMedical.Value = True on the current form AND chkPatient.Value = True on the previous form, Then. . . .

The parts I am unsure of are what code I write to indicate that BOTH have to be True, and also, how do I refer to the checkbox on the previous form, rather than having it look for that particular checkbox on the current form?
 
Just refer to the check boxes on the form that it resides.

If form1.chkMedical.Value = True AND form2.chkPatient.Value = True then .....
David Paulson


 
There are two ways to do this; either use a public variable and set it's value based on the checkbox on the earlier form or refer to the checkbox using the form name.
To create a public variable just declare it in the Declarations section of your main form using "PUBLIC" instead of DIM. This gives every form access to the variable. You can then set the value for this variable when the checkbox is changed.
To refer to a control on another form you just tack the form name itself onto the control name--if your form is called "Form1" and the control "chkMedical" then you would refer to it as "Form1.chkMedical"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top