I have a form called Form1. This form can be called by either FormA or FormB. Are there any ways whereby Form1 will know which one of these forms has called it?? If possible i do not want to use any MDI forms.
Printable View
I have a form called Form1. This form can be called by either FormA or FormB. Are there any ways whereby Form1 will know which one of these forms has called it?? If possible i do not want to use any MDI forms.
As far as I know there isn't.
You can create one yourself eg. by introducing a 'parent' in the form that you fill with a value by which it will 'know' by whom it is called.
how can that be done???
Put a commandbutton on Form1
Paste this code into the general section of Form1.
Put a commandbutton on FormA.Code:Option Explicit
Public intCalledBy As Integer 'Consider this your new property.
'You could also make it private and use get and let property statements.
' But that's exactly what VB will do under water when you use a public.
Private Sub Command1_Click()
Select Case intCalledBy
Case 1
MsgBox "Called by FormA"
Case 2
MsgBox "Called by FormB"
End Select
End Sub
Paste this code into the general section of FormA.
Make sure you have FormA as startup Form.Code:Private Sub Command1_Click()
Dim frmForm As Form
Set frmForm = New Form1
frmForm.intCalledBy = 1
frmForm.Show vbModal
Set frmForm = Nothing
End Sub
Is this what you mean?
hi,
try this way in formA where u are calling form1
load form1
form1.tag = me.name / form1.tag = formA.name
and access form1 properties
thanks a million laurens and krigans for the help..... i'll experiment with both codes.