Solved

To Know from which Form.

Posted on 2002-03-20
4
193 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 52

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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

Suggested Solutions

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…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…
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…

752 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