Solved

To Know from which Form.

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

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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 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…

777 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