View Full Version : Run a batch File


JBurlison
06-06-2008, 09:39 AM
How do i run a batch from VBA? i want to put the code in my on load event of my opening form. the batch file backs up the database

KenHigg
06-06-2008, 09:41 AM
Use the shell() function?

shell("c:\myBatchFile.bat")

???

boblarson
06-06-2008, 09:46 AM
How do i run a batch from VBA? i want to put the code in my on load event of my opening form. the batch file backs up the database

Ken's got it for you, but I think you might not realize that if you back it up while the database is open (which has to be since you are running this from a form) you run the risk of it not backing up properly. It may work and it may fail, because copying an mdb file while someone is in it can cause corruption in the copied file.

Just wanted you to be aware of the risk.

JBurlison
06-06-2008, 09:49 AM
humm so what would be the best way of baking up schedule it on the server?

boblarson
06-06-2008, 09:53 AM
You can do it from a batch file on your computer, or server, and kicked off with scheduler.