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

Finding the parent form from a Modal show

Status
Not open for further replies.

robdon

Programmer
May 21, 2001
252
ES
Hi,

Is there any way to find out the parent form from the child form, when you load a modal form.

IE...

When I show a form like this...

frmListsSearchItems.Show vbModal, frmListsMaintEdit

Is there any way for the frmListsSearchItems form to know that it was loaded from the frmListsMaintEdit form?

I know that I could keep track of it manually, just woundered if there was something like frmListsSearchItems.parent around??

Thanks,

Rob D.

ProIV Resource Centre
 
Might be a bit clunky but couldn't use a variable to hold the parent form name?
(I can see it coming... i'm gonna get shot down for this like a Prairie Dog stealing the wife's knickers)

Module
Code:
Public TrackForm As Form

frmListsMaintEdit
Code:
TrackForm = Me

frmListsSearchItems.Show vbModal, frmListsMaintEdit

frmListsSearchItems
Code:
debug.print "My Parent is " & TrackForm

Might not even work, but gotta be worth a go

HTH

Jag14

yosherrs.gif

[tt]'Very funny, Scotty... Now Beam down my clothes.'[/tt]
 
Hi,

Thanks for that...

I was hopeing that there was some 'automatic' property, rather than having to keep track of it..

Thanks anyway,

Rob.

ProIV Resource Centre
 
robdon,

Given that you are passing the OwnerForm argument in your frmListsSearchItems.Show vbModal, frmListsMaintEdit it seems likely that it could be retrieved using an API call but I do not know of a way it can be done in straight vb6 without a Public tracker variable or a user defined Property on frmListsSearchItems.

The API approach could be a question for Strongm when he gets back from his hols.

Why do you want to do this on a modal form? What are you trying to do?

regards Hugh,
 
Hi,

I want to have a form that is called from 2 different places and I need to do something slightly different depending on where it was called from.

I guess I will have to have a public var on the form, that gets set before I show the form, then I know what called it.

Just thought there might be something interal that knew...

Thanks.

Rob.

ProIV Resource Centre
 
robdon,

To avoid use of the Public tracker, (and unless there is an API which can determine the calling Form from Show's UserForm argument) you can MAKE it more 'internal' by placing a property on the Form to be called.

Assumming Form1 and Form2 are the calling forms;

Form1 code; Has 2 Command buttons
Private Sub Command1_Click()
Form3.CallingForm = Me
Form3.Show vbModal, Me
End Sub
Private Sub Command2_Click()
Form2.Show
End Sub

Form2 code; Has 1 Command button
Private Sub Command1_Click()
Form3.CallingForm = Me
Form3.Show vbModal, Me
End Sub

Form3 code; Has one command button
Dim OpenedMe As Form
Public Property Let CallingForm(Frm As Form)
Set OpenedMe = Frm
'you can now idenify the calling Form and all its properties
End Property
Private Sub Command1_Click()
OpenedMe.BackColor = QBColor(12)
End Sub
Private Sub Form_Activate()
Print OpenedMe.Name
End Sub

regards Hugh
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top