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!

backup of accessDB

Status
Not open for further replies.

TomG1

Programmer
Apr 12, 2001
25
0
0
BE
hello,

Is it possible to take a backup of an accessdatabase via VBcode? The user wants that it is possible to take a backup of his data on a floppy. And I haven't got a clue how to start, thx

Tom
 
Step 1 - make sure everyone's out of the database
Step 2 - copy the *.mdb file to the backup medium (ZIP it, or whatever)
Step 3 - tell everyone it's OK to get back into the app

Chip H.
 
chiph,

thx but i meant that the user wants that the backup is taken when he presses a button on the form.

Tom
 
You can use the above technique, but not safely. If someone other than your user is actively writing to the MSAccess database when the file copy happens, the backup is made with an unknown state. If you had some way in your code to signal other users not to make insert/update statements (network signalling, a "IsLocked" column in a table, etc) this would work.

Chip H.


 
How can you copy and save the mdb-file with VB-code?

 
Tom,
When the user clicks to backup the database, close the database then try and open for exclusive access. If you get an error then someone else has it open. You could at that point place a message within the database and have a timer to poll for any messages within your app which could then ask all users to log off as a backup is required.

Hope this helps

Nick
 
TomG1,

This may be to late but you can try this.

Private Sub mnuBackupItem_Click()
Dim SourceFile, DestinationFile, Default

Default = A:\backup.mdb"

SourceFile = "C:\original folder\original.mdb"
Prompt$ = "Would you like to make a backup copy of the database?"

reply = MsgBox(Prompt$, vbOKCancel, SourceFile)

If reply = vbOK Then
DestinationFile = InputBox$("Enter the pathname for the backup copy.", "File Backup", Default)
If DestinationFile <> &quot;&quot; Then FileCopy SourceFile, DestinationFile
End If

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top