Discussion Locked

Back up without using Back up

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Any Visual Basic experts please help!
I'm using MS Access 97 and need to make an autoexec file that will, when opened for the first time everyday, copy that database to another file and name it that day's date. This file is a multi-user file, and needs to be idiot proof, therefore I need it to be automatic and only copy one time a day.

5 replies

by glenda gable

I use a DOS batch file to backup my files nightly. My computer is shared by everyone in the small officer here, therefore the computer stays on all night. The DOS batch file is very simple:

CD\
xcopy32 {from} {to} /d /e
exit

you can use the help feature (/? I think) from the DOS prompt to get what extensions you need.

If this batch file is run nightly (either by someone manually clicking on an icon or set to run thru the task manager, it would seem fairly idiot proof (although I dont have to deal with many here so I have lost my "How would an Idiot get around this" train of mind :))

This is just a suggestion in case something else better doesnt come up :)

- Glenda

by agibbs

You said you were looking for a VBScript to do this . . .

You can use the VBScript FileSystemObject to copy files. Put the script in a code module and set a macro to run the script whenever the database is opened . . .

'>>>>>>>>>>BEGIN<<<<<<<<<

Dim fso, backupfilename, backupdir, dbfilename

Set fso = CreateObject("Scripting.FileSystemObject")

'set the name of the database file that needs to be backed up
dbfilename = "c:\access\mydatabase.mdb"

'set the directory to backup tobackupdir = "c:\backup\"

'build the daily backup filename
'example: 20011214.mdb
backupfilename = Year(Now()) & Month(Now()) & Day(Now()) & ".mdb"

'check to see if today's copy has already been made
If fso.FileExists(backupdir & backupfilename) Then
'today's backup already exists -- do nothing
Else
'make a copy of the database
fso.CopyFile dbfilename, backupdir & backupfilename
End If

'>>>>>>>>>>END<<<<<<<<<

Best,
Aaron

This discussion is closed to new replies.