Results 1 to 5 of 5
  1. #1
    Charandpat is offline Novice
    Windows 10 Access 2019
    Join Date
    Jul 2022
    Posts
    5

    Create Auto-Backup Database upon form opening Getting run time error 70

    I created Module I with:


    Public Function CreateBackup() As Boolean
    Dim Source As String
    Dim Target As String
    Dim a As Integer
    Dim objFSO As Object
    Dim Path As String
    Path = CurrentProject.Path 'get location of current folder
    Source = CurrentDb.Name
    Target = "I:\ProgramManagement\Contract_Compliance\Acce ss Database Actual Backup of Database and Tables\BackUpCP1LC" & "\BackupDBCP1LC "
    Target = Target & Format(Now(), "mm-dd") & ".accdb"


    ' create the backup
    a = 0
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    a = objFSO.CopyFile(Source, Target, True)
    Set objFSO = Nothing
    End Function

    In the actual form I did open open



    I am getting error Run time error 70
    The debug showing it does not like the following in my Module
    a = objFSO.CopyFile(Source, Target, True)

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    And error 70 is?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    Charandpat is offline Novice
    Windows 10 Access 2019
    Join Date
    Jul 2022
    Posts
    5
    It just says run time error 70 and then when I click on debug it points to my module line
    a = objFSO.CopyFile(Source, Target, True)

  4. #4
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    Try googling 'vba error 70'. That should give you a clue. To confim, trying copying to another folder.
    Also if that works, then try copying from another folder.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  5. #5
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    I don't see how you can make an integer equal what the method is supposed to do - namely copy a file from a source to a destination and either overwrite or not. I do not recall ever reading that the method provides a return value.

    This would be the first time I have ever seen it declared that an error is raised and provides only a number and no text message. Apparently the number is about trying to modify a write protected file.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Auto Backup Backend When Opening Frontend
    By Elfear in forum Programming
    Replies: 3
    Last Post: 04-25-2019, 10:58 AM
  2. Replies: 5
    Last Post: 06-21-2015, 02:51 PM
  3. Create a Macro to run backup of database
    By Harley Guy in forum Macros
    Replies: 7
    Last Post: 10-02-2014, 12:33 PM
  4. Replies: 8
    Last Post: 05-11-2014, 08:52 AM
  5. auto backup of database with every open
    By joshynaresh in forum Database Design
    Replies: 14
    Last Post: 10-01-2013, 10:10 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums