Running a Query and a Report through a scheduled task

G

Guest

Hello,

I'm wondering if anyone knows how I can make a scheduled task to do the
following things:

1) Run a report in a specific Access Database and print to pdf. (have about
9 of these I have to run weekly on Mondays)
2)Run a query in a specific Access Database and export results to an xml
file (Have to do this weekly on Fridays)

Thanks for any suggestions :)
 
S

Stefan Hoffmann

hi,
I'm wondering if anyone knows how I can make a scheduled task to do the
following things:
Use

"FullPathTo\MSACESS.EXE" "FullPathTo\Mdb.mdb" /cmd yourCmd

and use a start form and read the parameters behind /cmd with Command$
in VBA.


mfG
--> stefan <--
 
J

John W. Vinson

Hello,

I'm wondering if anyone knows how I can make a scheduled task to do the
following things:

1) Run a report in a specific Access Database and print to pdf. (have about
9 of these I have to run weekly on Mondays)
2)Run a query in a specific Access Database and export results to an xml
file (Have to do this weekly on Fridays)

Thanks for any suggestions :)

One way to do it is to create a Macro (RunReport let's say) which opens the
reports and then calls a VBA routine (using the RunCode method) to print or
export it.

To do so, use a command line in Scheduler like

"C:\Program Files\path\msaccess.exe" "D:\path\mydatabase.mdb" /x RunReport


John W. Vinson [MVP]
 
A

Albert D. Kallal

Well, you first need to write the code, and place it in a standard module.

So, I would assume your using Stephan's fantastic PDF maker here:

http://www.lebans.com/reporttopdf.htm

So, build some code that can be placed in a standard code module.

You then simply use a windows script to launch the mdb file..and run the
code.

I explain how to setup and run that batch file here:

how to run ms-access as a batch job
http://www.members.shaw.ca/AlbertKallal/BatchJobs/Index.html
2)Run a query in a specific Access Database and export results to an xml
file (Have to do this weekly on Fridays)

Are you using a2003? It has options for exporting data as xml. So, once
again, you need to write the code.

The transferDatabase does accept "xml" as an option......

So, I would first start exporting the data by hand (file->export) and play
with the xml export. When you have that working, then you can use code to do
the exprot...
 
G

Guest

The Windows Schedular has never played very well with
Access, because Access expects to be run by a logged
on windows user, not by a schedular. I don't know if that
has changed, but I don't expect so.

You may have better results using a third party schedular,
that is forced (because it is not written a part of the operating
system) to log in as a user.

Also, note that to export a report, you must have a default
printer defined (or a specific printer defined). Tasks that
run as system mean that the system must have a default
printer defined -- your default printer for your login won't
be visible if access is running in a system account.

(david)
 

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