Solved

Automatically running Microsoft Access macros

Posted on 2013-02-01
2
1,756 Views
Last Modified: 2013-02-15
I'm looking for some thoughts on a better way to streamline a cumbersome process I have manually running macros in a series of related Microsoft Access databases.  

The process begins by opening database 1 and running its macro.  As the macro completes, it closes the database.  Then I notice at some point that the database has closed.  I open database 2, run its macro, it closes.  After I notice it closed, I do the same for the next ten databases.  The length of time that each macro varies from day to day.  Each macro has to wait to begin until the macro in the previous database has completed.  The whole manual process can take hours.

One quick method I can think of would be to have each macro save a unique text file on the C drive as it completes.  Then have the Task Scheduler run a .bat file periodically that checks if the file exists.  If it exists, delete the file and open the next database (after setting the macro to autorun).  

This would run the whole series of macros as an automated jobstream.  Is there another easy way to do this without having to rewrite the old Microsoft Access processes?
0
Comment
Question by:LesterJebson
2 Comments
 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 500 total points
Comment Utility
You could link all the tables into a single master database, and then move your macro code over to the master database. You could then build a simple VBA module that would call each macro:

Docmd.RunMacro "YourMacro"
Docmd.Runmacro "YourrSecondMacro"

I believe Access will complete the first before moving to the second, but whether it actually "completes" would depend on what the macros do.

Better yet, do away with the macros and use VBA code to run the processes. VBA tends to give you much better control over situations like this.
0
 
LVL 16

Expert Comment

by:kmslogic
Comment Utility
You could use Windows Powershell to automate this kind of thing.  Generally the steps you'd take would be to set up your databases with a macro named AutoExec which Access will automatically run when you open the database.  Then in powershell you'd iterate through the databases and wait for each access process to end before starting the next one.

The powershell script would look something like this (assuming all your databases were in the c:\MyDB folder)

Set-Location C:\MyDB
get-childitem -Filter *.accdb | ForEach-Object { Start-Process $_.Name -Wait }

Open in new window

0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
2 Access tables, count verbiage used 6 19
Dcount unique 6 21
Mac-based software for Excel 8 19
MS Office subscription 11 29
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Outlook Free & Paid Tools
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…

728 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now