Solved

To Know from which Form.

Posted on 2002-03-20
4
154 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 49

Expert Comment

by:Ryan Chong
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…

772 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

10 Experts available now in Live!

Get 1:1 Help Now