|
-
Oct 27th, 2001, 02:07 AM
#1
Thread Starter
Fanatic Member
Identify the Calling Form
hello guys,
suppose i have got 3 forms in my project A, B and C. Both A and B forms can call the C Form. Now when C form is loaded i want to know which form has called the C form. is it possible to pass or receive any arguement (like functins and procudures) at the Form_Load and Form_Unload event?
pls guide me.
regards,
prakash
-
Oct 27th, 2001, 02:45 AM
#2
You can do this by creating a Module and defining a global variable in it. You will then set this global variable to a value of your choice before calling the 'C' form. Use one value for a call from the 'A' form, and another for the 'B' form. The Form_Load section of the 'C' form can then test this variable to see which form called it.
-
Oct 27th, 2001, 03:03 AM
#3
PowerPoster
Hi
there are many many ways to achieve this. eg using a Public variable as suggested by jdc and that is normally the method i use but u can also use the form's tag property. eg
VB Code:
'ON FORM 1
Private Sub Command1_Click()
Form3.Tag = Me.Name
Form3.Show
End Sub
'ON FORM 2
Private Sub Command1_Click()
Form3.Tag = Me.Name
Form3.Show
End Sub
'ON FORM 3
Private Sub Form_Activate()
MsgBox Me.Tag & " called me"
End Sub
Regards
Stuart
-
Oct 27th, 2001, 03:31 AM
#4
Thread Starter
Fanatic Member
i was expecting such answers. but i don't want to use global variables. when my form c is called i want to manipulate some variables of the calling form.
for eg. if form A has called form C then FormA.var1 = xyz
if form B as called form C then FormB.var2 = abc.
BTW what does this "Tag" property stands for
pls guide 
prakash
-
Oct 27th, 2001, 03:33 AM
#5
So Unbanned
The tag hold any extra data which your form could possibly use for these kinds of abstract things.
-
Oct 27th, 2001, 03:45 AM
#6
PowerPoster
Hi again
I dont quite understand what u mean by manipulating variables on the calling form.... sounds a bit spaghetti code but anyhow u can access the variables and controls like this...
VB Code:
'ON FORM 1
Public MyFormVar As String
Private Sub Command1_Click()
Form3.Tag = Me.Name
Form3.Show
End Sub
'ON FORM 2
Public MyFormVar As String
Private Sub Command1_Click()
Form3.Tag = Me.Name
Form3.Show
End Sub
'ON FORM 3
Private Sub Form_Activate()
Dim lfrm As Form
DoEvents
For Each lfrm In Forms
If lfrm.Name = Me.Tag Then
lfrm.MyFormVar = "U changed me"
lfrm.Text1.Text = lfrm.MyFormVar
Exit For
End If
Next
End Sub
Regards
Stuart
-
Oct 27th, 2001, 03:46 AM
#7
Frenzied Member
Digitalerror is a crackhead
-
Oct 27th, 2001, 06:03 AM
#8
PowerPoster
On form C, you have a Sub which manipulates the variables on the calling form I assume.
So on Form A & B, call this sub, and add an extra parameter.
FORM A / B
Sub
FormC.Show
FormC.ChangeVariables(Me)
End Sub
FORM C
Sub ChangeVariables(FormName as Form)
FormName.x = 1
FormName.y = 2
End Sub
That do?
-----------------------------------------
-RJ
[email protected]
-----------------------------------------
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|