calling .bat program on close program

G

Gordon Jones

Is there a way to call a dos batch program upon closing/exiting an Access
program? I have a "BkupMyProg.bat" program that saves the last 3 generations
of a MyProg_be.mdb file by cascading copy2 to copy 3, copy1 to copy2,
copyToday to copy1. I know all my users don't use it (because they call me),
and would like to incorporate the backup into the closing of MyProg. Is
there a way to do it?
 
D

Douglas J Steele

If it's a shared back-end, you're going to have problems for all but the
last user to log out.

What you can do is check whether or not MyProg_be.ldb exists in the same
folder as MyProg_be.mdb.

If it does, stop.

If it doesn't, you can use the Kill command to delete copy3, and the Name
command to rename copy2 to copy3, then copy1 to copy2. You can then use the
FileCopy command to create copy1

What I typically do, actually, is rename the current file (to copy1 in your
case), then use the CompactDatabase method to create a new version of the
current file.
 
R

Ron Hinds

Gordon Jones said:
Is there a way to call a dos batch program upon closing/exiting an Access
program? I have a "BkupMyProg.bat" program that saves the last 3 generations
of a MyProg_be.mdb file by cascading copy2 to copy 3, copy1 to copy2,
copyToday to copy1. I know all my users don't use it (because they call me),
and would like to incorporate the backup into the closing of MyProg. Is
there a way to do it?

Another possibility (in addition to the other's suggestions) is to create a
batch file to run your app. The last part of the batch file (which won't
execute until the users have closed your app) would do the copying for you.
As long as the users start the app by running the batch file (modify the
shortcut to do this) it will always happen when they close.
 
Top