Solved

Is it possible to schedule a query for export in access?

Posted on 2014-07-23
5
402 Views
Last Modified: 2014-07-24
I have a query that is linked to live data that I run every morning and export to excel.  Is it possible to have this done automatically on a scheduler of some kind?
0
Comment
Question by:garyrobbins
5 Comments
 
LVL 22

Expert Comment

by:Kelvin Sparks
ID: 40215326
The only way I know to do this is to use Windows Scheduler to start Access (probably a copy of your current db) which will have your report built into a macro. The startup string would be used to call the Macro (Google Access startup strings) which would then run the report, export it and close the database.


Kelvin
0
 

Author Comment

by:garyrobbins
ID: 40215373
How do i get a Macro to run on Access Startup
0
 
LVL 31

Expert Comment

by:Helen_Feddema
ID: 40215426
Years ago, I did this with a VBScript macro:

Set appAccess= CreateObject("Access.Application")
strDBNameAndPath = "E:\Documents\Access 2002-2003 Databases\General.mdb"
appAccess.Visible = True
appAccess.OpenCurrentDatabase strDBNameAndPath
appAccess.DoCmd.RunMacro "mcrPrintOrdersReport"
appAccess.CloseCurrentDatabase
Set appAccess = Nothing

Open in new window


Save it with the .vbs extension, and try running it from the Windows Scheduler.  The last time I tried it was probably in Windows ME and Office XP or thereabouts, so I don't know whether it would work now.
0
 
LVL 31

Assisted Solution

by:Helen_Feddema
Helen_Feddema earned 250 total points
ID: 40215432
You can run a macro from the startup of an Access database (not Access in general) by putting a RunMacro action into an AutoExec macro.
0
 
LVL 57

Accepted Solution

by:
Jim Dettman (Microsoft MVP/ EE MVE) earned 250 total points
ID: 40215658
<<The startup string would be used to call the Macro (Google Access startup strings) which would then run the report, export it and close the database.>>

  Google Access startup strings?  you've got to be kidding.

There are three ways to fire off:

1. Helen hit the first, call the code from a macro called autoexec.

2. Use the /x command line switch to call a specific macro at start-up (which Kelvin sort of hit)

3. Use the /cmd switch to pass parameters to the DB, view those parameters in code, and react accordingly based on the value.

all those are covered here:

http://www.experts-exchange.com/VP_73.html

at 23:50 in.

Jim.
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question