SendKeys?

  • Thread starter Thread starter Tom
  • Start date Start date
T

Tom

What I am trying to achieve is the following:

The user clicks on a command button which opens a 2nd form, when the 2nd
form is open, a 2nd command button is programatically clicked and an
existing procedure is run.

Is a Sendkeys statement the best way to click the 2nd Command button or is
there a better method?

Advice would be appreciated

TIA
Tom
 
Tom,

The SendKeys method is always the *worst* method for accomplishing anything!
It is notorious for doing anything but what it was intended to do, and
should therefore be avoided at any cost. After all, there is almost always a
better way to do whatever is desired. In your particular case:
* Put the code behind the 2nd command button in a general module; note that
you will have to change any occurrences of the Me. keyword to an absolute
reference like Forms![FormsName].
* Make the 2nd command button call the procedure in the general module
* Add an extra line of code at the end of the procedure behind the first
command button, to call the same procedure caklled by the second command
button. Cahnces aree this Call would be right after the DoCmd.OpenForm in
the 1st button's code.

HTH,
Nikos
 
Back
Top