Solved

To Know from which Form.

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

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

Suggested Solutions

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…

867 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

19 Experts available now in Live!

Get 1:1 Help Now