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.
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

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.
 

Forum statistics

Threads
1,141,429
Messages
5,706,402
Members
421,447
Latest member
arthuro2021

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top