Run Access from Command Prompt

J

John M

I am writing a batch job (the old way with DOS) to open 6 different
Access databases and run a macro in each one. In the bat file, I used the
command line documented in the Access 2002 Help.....

"C:\Program Files\Microsoft Office\Office10\msaccess.exe"
c:\foldername\database1.mdb /x macroname

"C:\Program Files\Microsoft Office\Office10\msaccess.exe"
c:\foldername\database2.mdb /x macroname

etc for 6 databases

The macro ran for the first database but the batch job terminated when
Access closed after running the macro. How can I return control back to the
batch job so it runs the macro in the other databases?
 
A

a a r o n . k e m p f

you should just move to SQL Server, which has native support for
scheduled the launch of a vbscript.

-Aaron
 
J

Jeff Boyce

John

You might want to try using your favorite search tool to see if someone has
worked this out before.

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
T

Tony Toews [MVP]

John M said:
I am writing a batch job (the old way with DOS) to open 6 different
Access databases and run a macro in each one. In the bat file, I used the
command line documented in the Access 2002 Help.....

"C:\Program Files\Microsoft Office\Office10\msaccess.exe"
c:\foldername\database1.mdb /x macroname

"C:\Program Files\Microsoft Office\Office10\msaccess.exe"
c:\foldername\database2.mdb /x macroname

etc for 6 databases

The macro ran for the first database but the batch job terminated when
Access closed after running the macro. How can I return control back to the
batch job so it runs the macro in the other databases?

Were there spaces in the folder names to the paths in database2,
database3 and so on? I suspect the first database didn't have any
spaces so it worked just fine. The others do have spaces and they
failed without telling you.

Putting a Pause at the end of the .bat/.cmd file will allow you to see
the results of the commands.

If that is the problem then put "" around the folder and path name for
the mdb just as you did for the msaccess.exe.

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
 
D

david

Note that this is almost never the best way to do it.

Most batch jobs are best handled with an ADO or
DAO object rather than an Access object.

However ADO and DAO objects are best handled
by VB script, the same as using VBA in your Access
application.

(david)
 
A

a a r o n . k e m p f

well you either adapt-- or you hire someone from india to help you.

Either way-- we were all 'not a programmer' once upon a time.
I had a hard time.. learning BASIC in 1982.
I had a hard time.. learning queries in 1997.
I had a hard time.. learning Excel VBA in 1999.

It's just one of those things that you've got to suck up and learn--
take baby steps.

if you're 'not a programmer'-- then concentrate on _MACROS_ instead of
modules.. get to know what's goin on.

It's not hard to pick up.
I just wouldn't bother hiding behind the 'I'm tool cool to be a real
geek' facade

-Aaron
 

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