Results 1 to 6 of 6
  1. #1
    Tomfernandez1 is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Feb 2011
    Posts
    74

    Copy Database Code Error

    Hello,



    I am trying to run a code for copying my database to a different location, but in running the code, I get the following an error, which when "debuged", has this line highlighted in yellow:

    oFSO.CopyFile sSourcePath & sSourceFile, sBackupPath & sBackupFile, True

    Any idea what the problem is? Here is the entire code:

    Public Function BackupCopy()

    'This function will allow you to copy a db that is open,

    'You must set a reference to the 'Microsoft Scripting Runtime' for the CopyFile piece to work!

    Dim OFSO As FileSystemObject

    Dim sSourcePath As String
    Dim sSourceFile As String
    Dim sBackupPath As String
    Dim sBackupFile As String

    sSourcePath = "C:\Documents and Settings\tommyf\My Documents\DBackup\"
    sSourceFile = "VANPOOL RIDERSHIP 1008.mdb"
    sBackupPath = "C:\Documents and Settings\tommyf\My Documents\DBackup\backup\"
    sBackupFile = "BackupDB_" & Format(Date, "mmddyyyy") & "_" & Format(Time, "hhmmss") & ".mdb"

    Set OFSO = CreateObject("Scripting.FileSystemObject")
    OFSO.CopyFile sSourcePath & sSourceFile, sBackupPath & sBackupFile, True
    Set OFSO = Nothing


    Beep
    MsgBox "Backup was successful and saved @ " & Chr(13) & Chr(13) & sBackupPath & Chr(13) & Chr(13) & "The backup file name is " & Chr(13) & Chr(13) & sBackupFile, vbInformation, "Backup Completed"

    End Function


    Thanks, in advance, for your help!

    Tommy

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    What's the error? It might not like the spaces in the file name.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Tomfernandez1 is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Feb 2011
    Posts
    74
    Hi Paul,

    The error reads "Run time error 76 - path not found"

    I rechecked the paths and placed underscores to fill spaces in the filename, but the error message persists.

    Any ideas?

    Tommy

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    I tested your code and it worked fine (Win XP Pro, Access 2000). I tried paths with and without spaces, so I don't think that's the issue. The error implies there's a problem with the path, though it wouldn't be the first time an error message was misleading. You're sure the path is exactly correct?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    Tomfernandez1 is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Feb 2011
    Posts
    74
    I am sure the path is correct. I am using 2003 version.
    Tommy

  6. #6
    Tomfernandez1 is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Feb 2011
    Posts
    74
    I think the problem is the code was written to run the same database it is written on. using a different database (different source path/file), the code and it worked fine.

    This changes the problem to being unable to run this code in a database as the source path. Is there a method for resolving this...?

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

Similar Threads

  1. Access copy/paste error in Shared mode
    By somm in forum Access
    Replies: 6
    Last Post: 12-16-2010, 08:59 AM
  2. Move or Copy a table to another database
    By Harley Guy in forum Access
    Replies: 7
    Last Post: 11-08-2010, 11:49 PM
  3. Replies: 1
    Last Post: 11-03-2010, 10:41 AM
  4. Replies: 4
    Last Post: 08-12-2010, 08:38 AM
  5. Copy one table to another database
    By ashthebear in forum Access
    Replies: 2
    Last Post: 06-15-2010, 08:46 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