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!

VB code to Backup MS Access databases

Status
Not open for further replies.

PJname

MIS
Jun 15, 2004
73
0
0
US
I would like to set up a backup function in a MS Access database where it will go and perform backups of other MS Access databases located in various directories .

Can someone send me the VB code to do this?

Thanks in Advance.....
 
What have you tried so far and where in YOUR code are you stuck ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 

PHV's 2nd FAQ has an answer for your question on #10.

As a tip, backing up a file database (like access) could be done with then NAME statement, if you like to look it up in the help file.
 
FileCopy will probably do what you want as well.

Ed Metcalfe.

Please do not feed the trolls.....
 
Using the following code to perform Database backups to a directory. Seems to be working correctly.

Function CompactDB3()
On Error GoTo CompactDB3_Err
Const conFilePath = "<current DBF location>"
Const conFilePath3 = "<directory where copy is to reside>"

newday4 = Now()
newday5 = Now()
firstday2 = Format(newday4, "ddMMMyyyy")
hourr = Format(newday5, "hhnn")

DBEngine.CompactDatabase conFilePath & "<database to be copied>", conFilePath3 & firstday2 & "_" & hourr & "_" & "<database backup name>.mdb"
 
Shorter
Code:
Function CompactDB3()
    On Error GoTo CompactDB3_Err
    Const conFilePath = "<current DBF location>"
    Const conFilePath3 = "<directory where copy is to reside>"

DBEngine.CompactDatabase conFilePath & "<database to be copied>", conFilePath3 & Format(Now(), "ddmmmyyyy_hhnn_") & "<database backup name>.mdb"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top