automated daily run of macro

stafire_18

Board Regular
Joined
Dec 8, 2004
Messages
162
Hi,
I am trying to find out if I can automate an access database macro to automatically run once a day without having to open the database. I don't use Access that often but am trying to automate a process for a website. If anyone has any clue as to how I can do this please help me. If you would like more information I'd gladly provide it, Thankyou.
 

Some videos you may like

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.

MyBoo

Board Regular
Joined
Aug 9, 2006
Messages
217
Search this forum. I just explained this very same issue for someone else... within the last month or so.

Create a new, blank db.
Create a form that when opened, will run your macro, then exit.
Set the form to open when the database is opened.
Put entry in Scheduler to start this database at whatever time you want it to run.
 

stafire_18

Board Regular
Joined
Dec 8, 2004
Messages
162
what if i need people going in & out of the form all day? this wouldn't work then correct because it will continue to run the macro over & over?
 

MyBoo

Board Regular
Joined
Aug 9, 2006
Messages
217
I don't believe there is ANY way you can run an Access macro without first starting Access and opening the database that contains that macro. (Doesn't mean it nothing exists)

You could create code VB code to do what you're asking, but then, you wouldn't be running an Access macro.

My suggestion did not mention your current database, although, depending on what your macro does, you would probably need to recreate at least part of your database.

Let's say your macro runs one query which creates a new table, populating it with records from that query, then exports that table to an Excel file. You can create another - totally seperate database, link the required tables from you existing database, copy the query and the macro to this new database. Then, you create a totally new form... simply a blank form, that when it opens, runs the macro. When the macro is done, the form closes and the application exits. You then set up whatever scheduling program you use so that this new database is opened at a specific time - specified by you. When it opens, the form opens, the macro runs, the form closes and the application is exited. This takes no longer than the time it takes to run your macro normally. Your users would never open this database.
 

VicRauch

Well-known Member
Joined
Mar 23, 2006
Messages
2,032
You can also, using the same database, pass to the database a parameter on the command line used to start the database. It would be the /cmd parameter (Look up Command Line in help). It will take your macro executing a function (which a macro can do) to retrieve the command parameter to see if this is the open that will finish running the macro assigned to a form when the form is opened. Actually, because this macro will at least start every time the database is opened, this macro can be named AutoExec so it will run whenever the database is opened.
HTH,
 

stafire_18

Board Regular
Joined
Dec 8, 2004
Messages
162
I have auto exect running a bunch of "clean up" tables & queries. Is there a code that says something to : if this form or databas is open prior to (example time) 12:00pm then run macro. or something to that effect? but only if it is open prior to 12:pm on a daily basis.
 

Watch MrExcel Video

Forum statistics

Threads
1,111,910
Messages
5,541,542
Members
410,549
Latest member
Anaarchie
Top