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!

How do I pass a parameter between the mainform and subform? 1

Status
Not open for further replies.

babowden

Technical User
May 31, 2004
6
US
In A2k, I have a mainform with a subform. During processing within the subform (under certain conditions), I set a variable (defined in the subform as Public Boolean) to True.

Later when I get back to the mainform, I check the variable (also defined in the mainform as Public Boolean) to see if it is True or False and proceed accordingly. However, the variable remains False regardless of being set in the subform. How can I pass a parameter between the mainform and subform?

Am I losing the value through initialization when focus returns to the main form?
 
you are loosing the value because the subForm isn't actualy a part of the main form...

you can either dim a global variable and set it there, or you can leave your main form open and reference your subForm from your mainform
 
Hi

Another method to do this would be:

define a (checkbox) control on the main form, call it say chkFlag, set its visible property to false if you do not want user to see it

in the subform you can reference this control using the "parent" prefix, thus

Parent.chkFlag = True

in the main form you can ference this control just like any other control on the form eg Me.chkFlag

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
The definitive answer is ...
A Public Variable declared in one Form is not recognized in another Form.
Declare your Public Variable in a MODULE (I call the Module PUBLIC) and all Forms will see it !!!
 
Erm - a form public defined in either the form or subform should normally be available (from "everywhere") as long as the form is open. Effectively, declaring "form publics" might be perceived as creating a form property, and it might be addressed as such.

Addressing the boolean bTest declared in a main form from a subform:

[tt]me.parent.bTest[/tt]

Addressing the boolean bTest declared in the subform (having the subform control name "frmsubTest"):

[tt]me("frmsubTest").Form.bTest[/tt]

Addressing the same from another form:
[tt]forms("mainformname")("frmsubTest").Form.bTest[/tt]

By what you've told us, it seems you're trying to address both the subform and main form public as if the where one variable, they are two separate form public variables, try using only one of them, for instance thru the method of referencing above.

Roy-Vidar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top