Solved

Name of owner form

Posted on 1999-01-23
9
143 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 69

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
 

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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 69

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

705 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now