Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Split Database Backup 1

Status
Not open for further replies.

DoctorJDM

Technical User
Apr 15, 2007
60
0
0
GB
Hi all

Have a split database and would like to back up both parts from a command button on a front-end menu form.

I can use a simple command like this for the front-end

If MsgBox("Do you want to back up the database?", vbYesNo + vbQuestion + vbDefaultButton2) = vbYes Then
CommandBars("Menu Bar").Controls("Tools").Controls("Database utilities").Controls("Back up database...").accDoDefaultAction
End If

This is not too elegant and I'd prefer it to name the file automatically, adding a date-stamp. Then do the more important back end.



 
If all you need is a full copy, you can use the File System object & its methods to copy and manipulte files (don't forget to set a reference to the Scripting Runtime library in your project).

"Don't be irreplaceable. If you can't be replaced, you can't be promoted."
 
Thanks Genomon, I'm sure you're right. Any pointers to doing it?

David
 
Code:
Dim fso As Scripting.FileSystemObject

Set fso = CreateObject("Scripting.FileSystemObject")

fso.CopyFile "source", "destination"

Set fso = Nothing

There are many other methods and proerties availabe. Do a help search on the File System object, and have a look at object browser in the IDE. Don't forget to set the library reference.

"Don't be irreplaceable. If you can't be replaced, you can't be promoted."
 
Thanks Genomon

Looks like I need to do some learning on this one.
 
You can also use the FileCopy command without the need for the scripting reference.
The syntax is:

FileCopy "source", "destination"

John
 
[bjrbarnett[/b]

FileCopy fails when the file is in use. FE would be in that state, because the code would be running form it.
 
Thanks guys, first to Genomon for the lead, then picked up by jbrbarnett.

The FileCopy command worked without need for scripting and without problems of 'file in use' since it is the backend database I'm backing up from the front end.

Used simple OnClick procedure to create copy with date appended

Dim CurrentDate As String
CurrentDate = Format(now,"DDMMYY")
FileCopy "C:\Backend\DB_be.mdb", "C:\Client\Backups\Copy" & CurrentDate & ".mdb"

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top