Activate cmdBotton on another Form

V

Vsn

Hi all,

I was wondering how could I activate (_Click) a command button on Form2 as a
result of a users action on Form1. Form1 will first open Form2 but what is
next...........in code?

Could some one give me a solution?

Thx,
Ludovic
 
D

Douglas J. Steele

By default, code in forms is always prefaced Private, so you have to do into
Form2 and change

Private Sub MyButton_Click

to

Public Sub MyButton_Click

Once you've done, that, you'd use

Call Forms_Form2.MyButton_Click

or

Call Forms("Form2").MyButton_Click

from within Form1.

However, if you've got the requirement to call the same code from two
places, why not put the code in a standard module, rather than in the module
associated with Form2?
 
V

Vsn

Douglas,

Thanks your help.

As an answer to your suggestion to put the code in a module, I use the
second form as a 'user interface', it reports to the user about the status
of its actions. Otherwise it would have been a better solution to put code
on a module level.

Cheers,
Ludovic
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top