access sendkeys - can i send 'Enter" or 'Return' ?

G

Guest

hi,

in access im am trying to run a macro.

OpenReport (conditioned)
OutputTo
Close
(repeat for other conditions)

The first time it runs ok, but the second time i run it it asks if it is ok
to save over the existing file. The answer to this will always be yes. I have
tried to SetWarnings before the OpenReport but that didnt work, so now im
looking for a SendKeys command to always hit the yes

thanks
 
G

Guest

Hi ashfire,

You simply have to have {Enter} as the keystroke in SendKeys. Functions
like {F4}, {UP}, {DOWN}, {LEFT}, {RIGHT} all work with SendKeys.

The problem I've found when running commands in a Macro is the same as
your's: I run a function or query in the Macro and it always asks if I really
want to do it, which requires me to press Enter or y several times for the
macro to run. For some reason, using SendKeys to automatically have Enter or
y pressed has not worked for me; Access acts as though the keys were never
pressed, even though I set the Wait option in SendKeys to Yes. If you have
any luck, please let me know. Thanks.
 
T

tina

if you're running Append, Update, or Delete queries from a macro, you can
suppress the warning messages by preceding the OpenQuery action with a
SetWarnings action, set to False, and another SetWarnings action, set to
True after the OpenQuery action. suggest you read up on the SetWarnings
Action topic in Access Help.

hth
 
G

Guest

Thanks, ill hold my hand up and say i forgot about the 'y' key......
To get it to work i have place the SendKeys command before OpenReport.

Tina, i tried using the SetWarnings, but again ill be honest and say i didnt
put one after the report was opened, ill do as you say and look into the help


thanks all
 
T

tina

my post wasn't intended to address your issue, ashfire. i was responding to
JornyO's comments. in your case: first, i'm wondering why you're opening
the report - are you printing it, as well as outputting it? you do know that
you can output the report without opening it to Preview, right? second, i
think the message you're getting is a Windows message, not an Access
message; if i'm correct, i doubt that a SetWarnings action will have any
effect, but you can give it a try.

if i am correct, then i don't think you can handle this issue in a macro. in
VBA, you might be able to run a Kill action, before outputting the report,
to delete the existing file before saving the new one. i don't know the
syntax, but i've seen it mentioned in the newsgroups, so you might try
Googling the groups for posts that address it.

hth
 

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