Solved

To Know from which Form.

Posted on 2002-03-20
4
182 Views
Last Modified: 2010-05-02
Hi,

I want to know the following.

There is a form called a.frm, b.frm, c.frm.

From a.frm I want to go to c.frm, from b.frm I want to go to c.frm.

But I want to know from which frm I am coming.  That if I go to c.frm from a.frm, In c.frm I should print that I have come from a.frm.  Like that If I go from b.frm I want to print to C.frm that I have come from b.frm.

Please tell me how to do that.

Thanks.

Natarajan
0
Comment
Question by:NatarajanSwaminathan
4 Comments
 
LVL 51

Expert Comment

by:Ryan Chong
ID: 6884643
Hi,

Maybe Create a Module, add this:

Public Sub CallForm(Byval frmFrom As Form,Byval frmTo As Form)
FrmTo.Caption = frmFrom.Caption
Unload frmFrom
End Sub

In form From:

Private Sub Command1_Click()
CallForm Me, b
End Sub
0
 
LVL 4

Accepted Solution

by:
trkcorp earned 20 total points
ID: 6884644
Perhaps a public variable on c.frm that can be set by a.frm or b.frm.

On c:
Option Explicit
Public sCallingFrm As String

Private Sub Form_Activate()
MsghBox "Calling Form: " & sCallingFrm
End Sub

In a.Frm:
c.sCallingFrm = "A"
c.Show

In b.Frm:
c.sCallingFrm = "B"
c.Show
0
 
LVL 2

Expert Comment

by:nahumd
ID: 6884897
I would simply put a global variable in module scope :

dim callingFrm as form

and then in the calling form , before you call the other form put :

set callingFrm = me
0
 
LVL 9

Expert Comment

by:Valliappan AN
ID: 6885001
I'd suggest to set the public variable, with the Form Name, instead of reference to Form itself, w.r.t. nahumd's one, which otherwise coincides to what I'd suggest.

Another option is to have a property in forms a,b & c, like CallingForm. So before calling the form, set its property. So, no need to have a global variable, if you use this only in few forms, when there are otherwise lot of forms. For a small project, global variables, should not be a memory issue. Like this:

Form A:
'Property definition for CallingForm
Private mCallingForm As String        

Property Let CallingForm(FormName As String)
    mCallingForm = FormName
End Property

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

'Call another form.
formC.CallingForm = Me.Name
formC.Show
------

Form B:
formA.CallingForm = Me.Name
formA.Show

------
Form C:
'Property definition for CallingForm
:
:

formA.CallingForm = Me.Name
formA.Show
----
Hope it helps.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Excel - Save a copy of work book 13 90
I need help using System.Web.HttpUtility.HtmlEncode in my VB.Net application 3 95
MsgBox 4 69
Problem to With line 4 63
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
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…
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…

820 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