Solved

Finding a form's parent

Posted on 1998-09-01
4
132 Views
Last Modified: 2010-04-30
I have a form,VendorInformation, that can be shown from two other forms,Requisitions and Purchase Orders, and a menu option, Vendor Maintenance.  Before I show the VendorInformation form from either the Requisitions or the Purchase Orders form, I hide the calling form.  Before I unload the VendorInformation form, I want to show the Requisitons or the Purchase Orders form.

How do I determine which form, Requisitions or Purchase Orders, called the VendorInformation form?
0
Comment
Question by:baileys
  • 2
  • 2
4 Comments
 

Author Comment

by:baileys
ID: 1432429
Edited text of question
0
 
LVL 4

Accepted Solution

by:
tomook earned 100 total points
ID: 1432430
The simplest method, which avoids API calls, is to add a property to VendorInformation which tells it which form called it. For example, insert the following in VendorInformation:

Private mCallingForm As String

Public Property Let CallingForm(Value As String)
  mCallingForm = Value
End Property

Public Property Get CallingForm() As String
  CallingForm = mCallingForm
End Property

When you are closing VendorInformation, merely check the value of mCallingForm to determine to which form you should return.

In each calling form (Purchase Orders, Requisitions), use this calling convention
  VendorInformation.CallingForm = "PurchaseOrders"
  VendorInformation.Show
Or:
  VendorInformation.CallingForm = "Requisitions"
  VendorInformation.Show

The first reference to any property of a form loads the form, but it will not be visible until the method Show is called. Please forgive any typos.
0
 

Author Comment

by:baileys
ID: 1432431
Thanks.  I am setting mCallingForm to the form instead of a string.
0
 
LVL 4

Expert Comment

by:tomook
ID: 1432432
Even better.
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

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…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…
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…

786 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