Hi everyone,
I want to somehow make a back-up copy of a database from visual basic, maybe by making an exact copy of the database or somehow. please someone, if you got any suggestions please post them...any codes ;) would be great. thanks
Printable View
Hi everyone,
I want to somehow make a back-up copy of a database from visual basic, maybe by making an exact copy of the database or somehow. please someone, if you got any suggestions please post them...any codes ;) would be great. thanks
MS Access type database is a single file DB and therefore backup is very simple - just copy original file to a backup folder:
VB Code:
FileCopy App.Path & "\Data\MyDB.mdb", App.Path & "\Archive\" & Format(Now, "mm_dd_yyyy") & ".mdb"
thanks, 1 question, :(
how would i go on about doing it...i want it to be called from a button, say the buttons name is cmdBackUp
please...help me..thanx again
Compile the following code and create a Scheduled Task so this program will run once a day (better during OFF hours):
VB Code:
Option Explicit Private Sub Form_Load() 'check for archive folder and create one if it doesn't exist If Dir(App.Path & "\Archive", vbDirectory) = "" Then MkDir App.Path & "\Archive" End If 'check for error folder and create one if it doesn't exist If Dir(App.Path & "\Error", vbDirectory) = "" Then MkDir App.Path & "\Error" End If End Sub Private Sub Command1_Click() ArchiveDB App.Path & "\Data\MyDB.mdb", _ App.Path & "\Archive\" & Format(Now, "mm_dd_yyyy") & ".mdb" End Sub Public Function ArchiveDB(sSource As String, sDestination As String) As Boolean '=============================================================================== On Error GoTo ErrHandler FileCopy sSource, sDestination Exit Function ErrHandler: '------------ Open App.Path & "\Error\erros.txt" For Append As #1 Print #1, Now() & vbTab & Err.Number & ": " & Err.Description Close #1 Exit Function End Function
thanks a lot....did you just type that whole code now...well anyway ...thanks a lot...you'r the man..
thanks a lot
bye
Yes, it's a brand new quick and dirty sample code for you Adrian. Despite it is a working sample - it needs some work to be done to tune it up.
Cheers. :wave: