apiCopyFile failure in Access Runtime version

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tan
    New Member
    • Oct 2006
    • 10

    #1

    apiCopyFile failure in Access Runtime version

    Hi, I have installed a runtime version of my Access 2000 programme on a pc (XP OS SP2). I have a button on my main swich menu that is used for the user to backup the database using the apiCopyFile method. This works fine on my development pc but produces a copy failure error on the runtime version,and I cant for the life on me figure this one out. I have also tried to use FileSystem object to no avail (and in fact ran into more issues with that due to the scrrun.dll reference). Does any one have any ideas? Would be much appreciated!

    Cheers

    Tania
  • ADezii
    Recognized Expert Expert
    • Apr 2006
    • 8834

    #2
    Originally posted by tan
    Hi, I have installed a runtime version of my Access 2000 programme on a pc (XP OS SP2). I have a button on my main swich menu that is used for the user to backup the database using the apiCopyFile method. This works fine on my development pc but produces a copy failure error on the runtime version,and I cant for the life on me figure this one out. I have also tried to use FileSystem object to no avail (and in fact ran into more issues with that due to the scrrun.dll reference). Does any one have any ideas? Would be much appreciated!

    Cheers

    Tania
    What exactly is the Error Description and when does it actually occur?

    Comment

    • tan
      New Member
      • Oct 2006
      • 10

      #3
      I am getting a file in use error ie 32 using err.lastdllerro r at time of copy execution. It's odd because i can copy an open databse in development/ full access but not in the runtim version. I tried copying an unopen file in the runtime version and the apiCopyFile worked fine...its simply to do with not being able to copy an open file and I have no idea how to get around this now!

      Comment

      • Lysander
        Recognized Expert Contributor
        • Apr 2007
        • 344

        #4
        Originally posted by tan
        I am getting a file in use error ie 32 using err.lastdllerro r at time of copy execution. It's odd because i can copy an open databse in development/ full access but not in the runtim version. I tried copying an unopen file in the runtime version and the apiCopyFile worked fine...its simply to do with not being able to copy an open file and I have no idea how to get around this now!
        If its an open file error, then something I used a long time ago might work. I'm afraid I've forgotten the details, but the concept is this.

        Instead of running your copy code, run a bit of code that opens a new database called 'BackupSys'. This would close your database and open backupsys whose only code and function would be a startup routine that backed up the now closed database, and then opened it again. When I used this in Access 2.0 I had to make all sorts of windows calls, and sendkeys statements to open the 'backupsys' database but I'm sure later versions of Access have made it simpler.

        Comment

        • tan
          New Member
          • Oct 2006
          • 10

          #5
          Thats an excellent idea!!! i think it will work...thanks!

          Comment

          • ADezii
            Recognized Expert Expert
            • Apr 2006
            • 8834

            #6
            Originally posted by tan
            I am getting a file in use error ie 32 using err.lastdllerro r at time of copy execution. It's odd because i can copy an open databse in development/ full access but not in the runtim version. I tried copying an unopen file in the runtime version and the apiCopyFile worked fine...its simply to do with not being able to copy an open file and I have no idea how to get around this now!
            There should be no problem with apiCopyFile() copying an Open File so the problem exists somehow with the Runtime Version of Access. Just to verify, try an alternate Method to copy the Open File and let's see how this works:
            [CODE=vb]Sub CopyFile(Source File As String, DestFile As String)
            Dim CopyString As String

            If Dir(SourceFile) = "" Then
            MsgBox Chr(34) & SourceFile & Chr(34) & " is not a valid file name."
            Else
            SourceFile = Chr(34) & SourceFile & Chr(34)
            DestFile = Chr(34) & DestFile & Chr(34)
            CopyString = "COMMAND.CO M /C COPY " & SourceFile & " " & DestFile
            Call Shell(CopyStrin g, 0)
            End If
            End Sub[/CODE]

            NOTE: If you are using Microsoft Windows NT, change the line:
            [CODE=vb]CopyString = "COMMAND.CO M /C COPY " & SourceFile & [/CODE]
            -------------------------------------- TO --------------------------------------
            [CODE=vb]CopyString = "CMD.EXE /C COPY " & SourceFile & [/CODE]

            Comment

            Working...