|
-
Apr 11th, 2004, 05:43 PM
#1
Thread Starter
Junior Member
[resolved]Backing-up a Ms Access database
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
Last edited by Adrian_struggel; Apr 11th, 2004 at 06:39 PM.
-
Apr 11th, 2004, 05:57 PM
#2
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"
-
Apr 11th, 2004, 06:00 PM
#3
Thread Starter
Junior Member
hey thanks RhinoBull,
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
-
Apr 11th, 2004, 06:17 PM
#4
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
-
Apr 11th, 2004, 06:26 PM
#5
Thread Starter
Junior Member
hey RhinoBull, your the MAN
thanks a lot....did you just type that whole code now...well anyway ...thanks a lot...you'r the man..
thanks a lot
bye
-
Apr 11th, 2004, 06:32 PM
#6
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|