RunCommand in a macro

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am getting an error that tells me the "Run" command is not available in my
db when I execute a macro. I am trying to use a macro to execute an append
query. I used to do this all the time in Access 2000, but now that I have
loaded 2003 I get this error. The msg indicates that I am in a read-only db
or in an unconverted db, but I'm not sure either of thses mean.

What am I missing?

Thanks,
Ted
 
Ted,

You would normally use an OpenQuery action in a macro to run an append
query.
 
I understand. My marco lines are:

echo off
setwarnings off
openquery Buildtbl1
runcommand Run
close Buildtbl1
openquery Buildtbl2
runcommand Run
close Buldtbl2
setwarnings On
echo On

I am trying to run 2 different append queries in this macro, but everytime I
do, I get the "RUN command is unavailable" error.
 
Ted,

Am I correct in understanding that Buildtbl1 and Buildtbl2 are both
Append Queries?

The OpenQuery action in your macro causes the query to "run". The
RunCommand/Run action does not apply. Similarly the Close action does
not apply, since after the append runs via the OpenQuery action, it is
no longer open, so nothing to close.

Also, the SetWarnings/Yes action at the end does not achieve anything...
Warnings are automatically set back on at the end of the macro anyway.

Also, I am not sure of the purpose of the Echo action in this context,
but I can't see how it would achieve anything significant either.

Therefore, I would suggest to change the macro to...

SetWarnings No
OpenQuery Buildtbl1
OpenQuery Buildtbl2
 
Steve,

Flawless victory! You were right. I took out the extraneous lines and the
macro ran perfectly. THat's what I get for being self-taught and figuring it
out on my own. I used the openquery, runcommand, close structure all the time
before I upgraded to 2003.

However, none of that matters because you made it work...and now macros are
a lot shorter for me to write.

Thanks,

Ted
 
Ted,

On reflection, I think in your previous usage, for it to have worked the
way you described, you must have been opening the queries in Design view.
 
Back
Top