Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2002
    Posts
    8

    Unanswered: making a backup of a db

    Hi there,
    I was hoping to add a button that would simply copy my datebase (to disk or computer) so that there is a backup copy. am i suppose to use MakeReplica or is there something easier (if makereplica is even what i wanted in the first place ;o) Thanks in advance

  2. #2
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    try:

    'define where a backup will be located
    Global Const BackupPath = "C:\COMMGUIDE\BACKUP\BAK"

    Public Function DoBackup() As Boolean
    'makes a backup copy to const.BackupPath
    On Error GoTo err_DoBackup
    Dim SaveBakAs As String
    Dim theDataObject
    Dim theData
    Set theDataObject = CreateObject("Scripting.FileSystemObject")
    Set theData = theDataObject.GetFile("C:\COMMGUIDE\COMMGUIDE_BE.M DB")
    'generate a unique name
    SaveBakAs = DoBackupMakeName
    theData.copy SaveBakAs, True
    'return success
    DoBackup = True
    exit_DoBackup:
    Set theData = Nothing
    Set theDataObject = Nothing
    Exit Function
    err_DoBackup:
    MsgBox Err.Description, vbOKOnly, "Backup Error"
    DoBackup = False
    Resume exit_DoBackup
    End Function

    Private Function DoBackupMakeName() As String
    Dim BakName As String
    Dim bitName As String
    bakname = Year(Now())
    bitName = Month(Now())
    If Len(bitName) = 1 Then bitName = "0" & bitName
    bakname = bakname & bitName
    bitName = Day(Now())
    If Len(bitName) = 1 Then bitName = "0" & bitName
    bakname = bakname & bitName
    bitName = Hour(Now())
    If Len(bitName) = 1 Then bitName = "0" & bitName
    bakname = bakname & bitName
    bitName = Minute(Now())
    If Len(bitName) = 1 Then bitName = "0" & bitName
    bakname = bakname & bitName
    bitName = Second(Now())
    If Len(bitName) = 1 Then bitName = "0" & bitName
    bakname = bakname & bitName
    bakname = BackupPath & bakname & ".bak" 'the fully formed file path/name/ext
    DoBackupMakeName = bakname
    End Function


    izy
    Last edited by izyrider; 02-05-03 at 17:50.

  3. #3
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    sorry - there were a number of typos (back/bak, but/bit) in the first attempt: i think i edited tham all correctly now.

    izy

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •