5 replies
by dklippert
Here's a BAT file from the forums:
How about writing a simple DOS batch file?
rem MYBACKUP.BAT by Don Leverton/Trevor Best
cls
echo off
rem ********************************************
rem This is a batch file that "backs up"
rem yesterday's MYFILE.MDB
rem by repairing, then compacting, (and renaming
rem in a different directory)
rem and then opens it again today.
rem You actually get 2 days worth of backup...
rem One copy in c:\backup, another in c:\recycled
rem Note that youwill have to create an icon
rem (shortcut) that runs
rem this batch file, and ALWAYS open MYFILE.MDB
rem using this Batch File.
rem **************************************
If Exist C:\BACKUP\BACKUP.MDB MOVE C:\BACKUP\BACKUP.MDB C:\RECYCLED
rem (used MOVE above because it does not prompt
rem you about overwriting)
c:\msaccess.exe c:\access\myfile.mdb /repair/compact c:\backup\backup.mdb
C:\ACCESS\MSACCESS.EXE MYFILE.MDB
exit
rem **********************************************
by inquisitive
by c1980
You could create an EXE using VB and use the following code to a sub proceedure (a very simple process):
'Delete the previous back-up, if one exits (Could use API function to send it to the bin instead)
On Error Resume Next
Kill sPath & sBakName
On Error GoTo ErrHandler
'Make a new back-up of the MDB with the name in the sBakName variable (in case something goes wrong)
FileCopy sPath & sDBName,sPath & sBakName
'Compact the MDB into the name in the sCmptName variable
DBEngine.CompactDatabase sPath & sDBName, sCmptName, , ,sPass
'Delete the orig. MDB '(Could use API function to copy over instead)
Kill sPath & sDBName
'Rename the compacted MDB back to the orig. name
Name sCmptName As sPath & sDBName
ExitProceedure:
Exit Function
ErrHandler:
'Do something with the errors
resume ExitProceedure
by inquisitive
by inquisitive
This discussion is closed to new replies.
Trending Software posts
Sort by Trending