Autoexecute when Access is open or closed

sinema

New Member
Joined
Jun 1, 2019
Messages
2
I have been looking for my original post or the post that I think I thought was mine but was someone else's.

Anyway, we have an access tool that someone else built. Each day I press a "Run All" button and 20 mins later I finishes and I continue. We are trying to have this run automatically a few times a day.

I just do not know how to make it happen. is it even possible?

Is there a resource to figure out how?

It's on a Form and when right click and select build event it will show the Form_Lookup Tasks and there's a section called "Private Sub cmdsyncrunall_Click()" that contains everything I want it t do.

I just do not now hw to make it run on a timer.
 

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
51,177
Office Version
365
Platform
Windows
You can automate Access databases a few different ways.

1. You can create a macro named "AutoExec". These will run automatically whenever a database is opened.
- or -
2. Set a Startup Form on your database (a Form that opens automatically whenever a database opens), and add VBA code that runs on the "Load" event of the Form.

Then you can use some scheduling software (i.e. Windows Scheduler) to open the database at specified times of the day, which should kick off your Macro/VBA code.

I typically make a second copy of the database that does this, so users aren't typically using the version which runs automatically.

There are other variations, such as calling a specific macro/vba code to run from the scheduler, such as the one shown here: https://office-watch.com/2017/scheduling-an-access-task/
 

Micron

Well-known Member
Joined
Jun 3, 2015
Messages
1,742
@sinema, you didn't say if this is a shared db. If there are concurrent users the action might disrupt what they're doing; maybe even introduce corruption. It seems like there must be a lot going on for it to take 20 minutes to finish. I would agree with Joe4 that a separate db might be best. Question is, what is the best way to initiate the action? A form timer will only work if that db is open. Another method would be to call the procedure from the db you are "continuing" in - provided that doesn't interfere with anyone.
 

Forum statistics

Threads
1,078,437
Messages
5,340,270
Members
399,361
Latest member
Linford

Some videos you may like

This Week's Hot Topics

  • Problem with Radio Button's format control
    I am creating an employee evaluation template (a sample is below) Column A is the category Column B, C D, E and F will be ratings (unacceptable...
  • Last Display on userform to a Listbox
    [CODE=vba] lstdisplay.ColumnCount = 15 lstdisplay.RowSource = "A1:O600000" [/CODE] So when i do this it Displays everything on the sheet i am...
  • Rename and move files to a new location
    Dear all, I have an excel file with the following information. The actual file name is at column A but i want to rename it using the following...
  • Help with True/False Formula
    Hello! Am stumped how to fix this formula, in which my result returns 'True', but it should return False. =IF(AG2=True...
  • Clear extra characters from a provided range of cells
    Dear All, I have following code which gives me desired output to remove extra characters from a provided range. But it takes too much time when...
  • Help with Current and highest streaks
    Hi there, I've just joined the forum and this is my first post. I've already spent quite a bit of time searching the net and this forum for a...
Top