Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to use batch file to open Access and run single command

Status
Not open for further replies.
May 30, 2001
17
0
0
US
I have an access app that I open every morning and click a single command button that checks a bunch of files for errors. Is there a way to open access through a batch file and then invoke this single command? I want to automate this process so when I arrive to work in the morning, the scan has already taken place.

Opening Access in a batch is not hard, but invoking the single command (button on the opening form) evades me.

Any one ever do something like this before?

Thanks.
 
why don't you set it up on the autoexec macro?
Put the code currently behind the button in a seperate module, then create a new macro, call it Autoexec, set the 1st macro command to RunCode and in the parameters at the bottom put the name of your function.
Every time you open the database it will check these files.
The only thing you might want to consider (if you haven't already) is what happens if errors are found?

HTH

Ben ----------------------------------
Ben O'Hara
bo104@westyorkshire.police.uk
----------------------------------
 
Or you could write a short VB or VBScript application that instantiates an Access application object and then runs a function. Something like the following. (Extract from Access Help file)

Private Sub RunAccessSub()

Dim appAccess As Access.Application

' Create instance of Access Application object.
Set appAccess = CreateObject("Access.Application")

' Open WizCode database in Microsoft Access window.
appAccess.OpenCurrentDatabase "C:\My Documents\WizCode.mdb", False

' Run Sub procedure.
appAccess.Run "Greeting", "Joe"
Set appAccess = Nothing

End Sub

Now this wouldn't help much unless you were to schedule the script to be run using the Start\Programs\Accessories\System Tools\Scheduled Tasks in Windows 2000. It also exists back to Windows 95 but I'm not sure where.

Steve King
Growth follows a healthy professional curiosity
 
there is a much easier way(at least i think so.)

go into access help and search for
command line switch

you can open access with a command line switch to run a certain macro... so when you double click it (or you can schedule it, or put it in the startup folder on the start menu) it will open access, open the mdb you need opened, and even still, run the macro... have a good one:)

JHauge@jmjpc.net
Life is change. To deny change is to deny life.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top