+ Reply to Thread
Results 1 to 3 of 3

Thread: backup button

  1. #1
    Registered User
    Join Date
    10-17-2010
    Location
    Naga, Philippines
    MS-Off Ver
    Excel 2003
    Posts
    34

    backup button

    anyone know how to make a backup button in the mainform? ive been searching in the google and it seems too hard to find 1....

  2. #2
    Forum Guru, retired Admin royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    25,616

    Re: backup button

    A bit more explanation will be required
    Hope that helps.

    RoyUK
    --------
    If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need

    For Excel Tips & Solutions, free examples and tutorials why not check out my downloads

    New members please read & follow the Forum Rules

    Remember to mark your questions Solved and rate the answer(s)

  3. #3
    Registered User
    Join Date
    10-17-2010
    Location
    Naga, Philippines
    MS-Off Ver
    Excel 2003
    Posts
    34

    Re: backup button

    ok i found a code on how to make a backup button on the form
    here it is

    Private Sub Button_Backup_Click()
    Dim str As String
    Dim buf As String
    Dim MD_Date As Variant
    Dim fs As Object
    Dim source As String
    Const conPATH_FILE_ACCESS_ERROR = 75
    On Error GoTo Backup_Button_Backup
    'buf = Back Up Folder
    'buf is created if it does not exist
    'CurrentProject.Path = the path that the FE is located
    buf = CurrentProject.Path & "\Backups\"
    MkDir buf
        Resume Backup_Button_Backup
    Backup_Button_Backup:
    'Use yyyy-mm-dd hh-mm-ss as folder name. Change as needed.
    MD_Date = Format(Date, "yyyy-mm-dd ") & Format(Time, "hh-mm-ss")
    str = CurrentProject.Path & "\Backups\" & MD_Date
    'Source = where the data is stored
    source = CurrentProject.Path & "\Data\"
    MkDir str
    Set fs = CreateObject("Scripting.FileSystemObject")
    'Change the file extension as needed
    fs.CopyFile source & "*.accdb", str
    Set fs = Nothing
    MsgBox "Data backup at " & vbCrLf & MD_Date & vbCrLf & "successfully!", _
            vbInformation, "Backup Successful"
    Exit_Button_Backup:
      Exit Sub
    Err_Button_Backup:
      If err.Number = conPATH_FILE_ACCESS_ERROR Then
        MsgBox "The following Path, " & str & ", already exists or there was an Error " & _
               "accessing it!", vbExclamation, "Path/File Access Error"
      Else
        MsgBox err.Description, vbExclamation, "Error Creating " & str
      
    End If
        Resume Exit_Button_Backup
    End Sub
    but when i ran it a debbuger appear in the line that was highlighted...

    fs.CopyFile source & "*.accdb", str
    this line is in yellow...

    can anyone fix the code?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.2.0