Referencing existing form?

  • Thread starter Thread starter Grumpy Aero Guy
  • Start date Start date
G

Grumpy Aero Guy

How do I reference a method on an open form from ANOTHER open form?

What is the correct object reference, assuming the form name frmTest ???

Assume, from frmTest2 I would like to invoke the following method in
frmTest1....

___________.commandbutton1_click(sender,e) ????
 
Hi Fred,

You should be able to declare the method as Friend: -

Friend Sub commandbutton1_click in frmTest1

Declare frmTest1 with events in frmTest2: -

Dim WithEvents frm1 as frmTest1

Then instantiate the method within frmTest2's calling method

[frmTest2].commandbutton1_click(sender,e)

frm1 = new frmTest1
frm1.commandbutton1_click(sender,e)

That should do it (Fingers crossed :-)

HTH,

Phil
 
Grumpy Aero Guy said:
How do I reference a method on an open form from ANOTHER open form?

What is the correct object reference, assuming the form name frmTest ???

Assume, from frmTest2 I would like to invoke the following method in
frmTest1....

___________.commandbutton1_click(sender,e) ????

You will have to make a reference to your instance of 'frmTest' available to
'frmTest2'. You can do that by passing a reference to a property or method
of 'frmTest2'. Then you can use '<reference>.Button1.PerformClick()' to
raise the button's 'Click' event.
 
Example?

--


Frank Bachman
(Grumpy Aero Guy)


Herfried K. Wagner said:
You will have to make a reference to your instance of 'frmTest' available
to 'frmTest2'. You can do that by passing a reference to a property or
method of 'frmTest2'. Then you can use
'<reference>.Button1.PerformClick()' to raise the button's 'Click' event.
 
Back
Top