Backing-Up DB to CD.

LEXCERM

Registered User.
Local time
Today, 19:33
Joined
Apr 12, 2004
Messages
169
Good day all,

I have read quite a few threads about backing-up DB's, but have not come across any coding that specifically shows you how to back-up a DB to CD. Maybe someone can point me in the right direction.

I have a simple db (not split into FE/BE) and I want to allow a user to copy the current DB to a CD. On my main form I have the following coding on my EXIT button, but I also want to incorporate some code to allow the user an option to save the DB to CD at end-of-day:-

Private Sub exit__Click()

Dim i As Integer
For i = 1 To CommandBars.Count
CommandBars(i).Enabled = True
Next i

CommandBars("Menu Bar"). _
Controls("Tools"). _
Controls("Database utilities"). _
Controls("Compact and repair database..."). _
accDoDefaultAction

DoCmd.Quit

End Sub

Any help will be greatly received.

Regards,
PAUL.
 
what's your purpose of putting your db on a CD? it cannot be opened since CDs are read only media.

If you want to put your db on a CD just for backup purposes, you can simply use your normal burning software rather than using MS Access.
 
Thanks maxmangion for your reply.

The DB is used by a single person in a small business. I was thinking of having a piece of code set-up to make it easier for him to back-up the data each night onto a CD to take home with him. Of course, he can just copy and paste the file using My Computer etc, but I thought it would be neater to automate the process using code.

Thanks again,
PAUL.
 
Why not call the application from a batch file and put the code in the batch file to copy the db to CD?
 
Thanks for your suggestion Neil.

Are we talking MSDOS here? If so, I wouldn't know where to start!

Could you please elaborate or give an example.

Cheers,
PAUL.
 
I suppose batch programming is a bit of a lost art. I'm showing my age!

Create a text file on your desktop called database.bat (the database bit can be anything upto 8 characters, letters or numbers or the underscore character)

Put as the first line of your text file the full UNC path to the database. If it includes spaces, then enclose this in quotes.
As the second line use a copy satement to copy the database to the CD.

For example
Code:
"C:\Documents and Settings\neg\My Documents\db2.mdb"
copy "C:\Documents and Settings\neg\My Documents\db2.mdb" D:\*.*
In thise case the CD is Drive D:

Then if you double click on the batch file icon on the desktop, this will first run the database. Then when you exit the database, it will execute the copy command.
 
Thanks alot Neil. I got this to work nicely even when I changed a few of the parameters for testing purposes, i.e. saved the file to desktop rather than D:\.

The only slight snag was that the file opened but I had to manually close it for the copy to continue. Is this how it should work, or can you get the BAT file to close the DB automatically?

A big thanks once again.

Paul.
 
Mmm...

The batch file is suspended while your application runs so there's no interaction. I had assumed you wanted to backup the database whenever it was closed, so the sequence of events was:
1. Open database
2. Use database
3. Close database
4. Back up to CD

If all you want is a batch file to do the backup, you don't need the first line at all.

Try the following that's a little more polished for just the backup:
Code:
@ Echo off
Echo Please insert a new CD in the drive
Pause
copy "C:\Documents and Settings\neg\My Documents\db2.mdb" D:\*.*
Echo Backup complete
Pause
 

Users who are viewing this thread

Back
Top Bottom