Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Name of owner form

Posted on 1999-01-23
9
147 Views
Last Modified: 2013-11-23
I have a frmMain that calls a frmSub like this:

private sub frmMain()
  frmSub.Show 1
end sub

So, in frmSub, how do I check that it is frmMain that calls frmSub?
0
Comment
Question by:gen101298
  • 3
  • 2
  • 2
  • +1
9 Comments
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 1470289
You have to keep a global variable or an array that keeps the calling chain!

I know it's not a beautiful but it's an easy one.

One way to facilitate it is instead of saying frmSub.Show, call a method of your own (like FormOpen) that will handle this for you.

0
 
LVL 12

Expert Comment

by:mark2150
ID: 1470290
How about:

private sub frmMain()
frmSub.Tag = Me
frmSub.Show 1
end sub
0
 
LVL 7

Expert Comment

by:Inteqam
ID: 1470291
in frmSub , define a varible lets say ParentForm of type form.

then before showing the form, code the following

set frmSub.ParentForm = Me

and you can refer to frmMain in frmSub by using ParentForm

hope this will help/
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:gen101298
ID: 1470292
Inteqam, I still cannot get what gave me.  
I declare dim ParentForm as Form, and
set frmsub.ParentForm = Me,
but there's error for .ParentForm!
Can u explain in more detail, give a more detail example.  Thanks!
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 1470293
Did you define a public property named ParentForm in your form module.
0
 
LVL 12

Expert Comment

by:mark2150
ID: 1470294
Are you trying to pass the parent form down to the child or the child back to the parent?

Your parent form should be able to shoot in it's name into the *CHILD* forms .Tag property (this is a variant and will accept most anything). Then the *CHILD* can read it's own .Tag property to discover who called it.

You can even do something as simple as:

child.tag = me.caption
show child

This will give the caption of the parent form to the child.

Now the child can test:

SELECT CASE ucase(trim(Me.tag))
    CASE "MAIN FORM"
    ...
    CASE "OTHER FORM"
    ...
    CASE ELSE
    ...
END SELECT

Now if you're doing the case where you want to hide the parent and have the child redisplay it on the way out, you can code it modally:

(parent calls child)

Me.Hide
Child.Show 1
Me.Show

(child exits)

Me.Hide

M


0
 
LVL 7

Expert Comment

by:Inteqam
ID: 1470295
forget to tell you , make the ParentForm public :

Public ParenForm as Form.

0
 

Author Comment

by:gen101298
ID: 1470296
Inteqam, u wrote
set frmSub.ParentForm = me, this confused me, so I change it to
set ParentForm = me, before that I declare Public ParentForm as Form as u told me,
so it works!  I like this method, it's much shorter...thanks!
Come claim ur points!


0
 
LVL 7

Accepted Solution

by:
Inteqam earned 10 total points
ID: 1470297
thanks
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question