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

Checking which form is the Parent 1

Status
Not open for further replies.

jmob

Programmer
Jun 21, 2005
58
US
I am opening a subform by use of a button. Within this form I would like to be able to check if the parent form is a certain particular form. This matters because I would like the subform to do different things based upon which form it is called from. Something like If (Me.Form.Parent = [My Form]) ???
Thanks.
 
probably quicker to test the name...

if me.parent.name = "whateverFrmName"

--------------------
Procrastinate Now!
 
I get an error "invalid reference to parent property" when using that. It wont let me access the name property. Any idea?
 
Either me.parent.name or me.parent.form.name should give the name of the parent form if this in fact is a subform ... but since you say you "open a subform" I'm not sure ... you don't open subforms, you open the main form on which the subform may reside (another hint that this may not be a subform, lies in the errormessage, it's probably the 2452 - "The expression you entered has an invalid reference to the Parent property", which is the error I get when I try to reference that property from a single/main form, which does not have a parent form ...)

Roy-Vidar
 
RoyVidar- you said exactly what my problem is. (I don't have a subform, just another form) Is there a way to reference the main form from the pop-up form? They are not linked at all.

I have this: (Calendar0 is on a separate form that pops up)
Forms![Form A]!theDate = Me![Calendar0].Value
I would like to check if [Form A] was actually the main form first though.
 
Why not passing the name of the calling form in OpenArgs ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
OpenArgs works great for the main forms, however I am now trying to access a subform. I am using this code below after I have used the OpenArgs to tel which form I am at. I would like to access a subform in FormA.
This works for a main form
Forms![FormA]!dtDate = Me![Calendar0].Value
however I need to access a subform of FormA. Any ideas? Thx!
 
Forms![FormA]![subform control].Form!dtDate = Me![Calendar0].Value

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top