Solved

Name of owner form

Posted on 1999-01-23
9
144 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
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…

910 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

23 Experts available now in Live!

Get 1:1 Help Now