Click a button with automation technology

R

Rogers Fei

Hi, all
I'm trying to automate an Access Application. I can access the "Forms"
and "Reports", but I do not have a good and efficient way to access the
controls.

e.g. I want to click a button or raise a click event on a specified button
on a "Form" after it is opened. Currently, I just use the following codes:
DoCmd.GoToControl MyForm.Controls("MyControl") //Focus the button control
SendKeys " ",true //Press space key to fire a click event on this
button

I'm not very satisfied with the preceding code because it is not stable.
Could anybody tell me whether there's a better to do this? Or can I invoke
the event handler function (private sub CmdButton_Click....) from outside?

Thank you very much!
 
B

Brendan Reynolds

Could anybody tell me whether there's a better to do this? Or can I invoke
the event handler function (private sub CmdButton_Click....) from outside?

You can if you change its scope to public, e.g. Public Sub cmdButton_Click.
 

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

Top