sendkeys requires add-in?

P

Phil Freihofner

I have a simple macro (three lines) that opens a form, moves the focus to a
button control, and then attempts to use a "Sendkeys" command to press the
button.

For the Keystrokes property of the macro, I put in the following:

{"ENTER"}

When I run this macro, the form loads and the focus is on the button
control, but the button does not get pressed, and I get the following error
message:

"The SendKeys action requires the Microsoft Access Utility Add-in to be
loaded.
Rerun Microsoft Access or Microsoft Office Setup to reinstall Microsoft
Access and the Microsoft Access Utility Add-in."

When I checked the installation disk (Version 2002), there was no such
Utility Add-in to be found. Also, a search at the Microsoft Support Website
did not turn up a specifically named "Utility Add-in" for Access.

If there is another way to "remotely" open the form and hit a button to make
it execute (note, the Button_OnClick() VBA code is a Private function and
should stay that way), I would love to hear about it.

Many thanks!
 
P

Phil Freihofner

I changed the command in the SendKeys to the following:

"{ENTER}"

Now, the macro executes without giving an error message, but the button
still does not get pressed. Any ideas?
 
P

Phil Freihofner

Doh!!

The proper syntax was to put in the following:

{ENTER}

no quotation marks anywhere.
Now it works just fine.

No further help needed, thanks.
 
P

Phil Freihofner

Well, the SendKeys syntax may be right, but it still doesn't press the button.
How does one automate an Access Form GUI?
 
J

Jeanette Cunningham

SendKeys won't work in Vista (I haven't tried in Win 7).
Would you explain in more detail what you are trying to do.

If you have a form open, you can call a button click like this:
Call Forms("FormName").cmdButton3_Click,
as long you make the code for cmdButton3_Click a public sub or function
instead of a private sub or function.

Note: replace FormName and cmdButton3 with the names of your objects.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
J

Jeanette Cunningham

I read in another post that you are trying to set up some automated testing.
I haven't heard of any way to do automated testing in an access database.

From my point of view, it would be far too much work to try to write code to
do automated testing for any of my databases.
So much of what needs to be tested depends on what users do when they are
interacting with the screens.

Here are some ideas:
Liberal use of Debug.Print will allow you to test strings, criteria,
dlookups, dcounts, queries in vba code, variable values, property values,
open args and much more.
Functions can replace subs in some places, and if you examine the return
value from the function, you can determine if it is working.
For example, you can write a function that you use to open forms. Its return
value can tell you whether the form opened successfully.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 

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