Solved

Name of owner form

Posted on 1999-01-23
9
149 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

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

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Excel Automation VBA 19 116
Sub or Function is not defined 6 59
adding "ungroup sheets" to existing vbs code 5 75
how to loop through and process two columns in excel 8 72
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

710 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