Solved

Name of owner form

Posted on 1999-01-23
9
150 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
[X]
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
  • 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 

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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…
Suggested Courses
Course of the Month10 days, 6 hours left to enroll

628 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