Alternatives to FileCopy?

IR_Moon

Registered User.
Local time
Tomorrow, 10:16
Joined
Jun 6, 2006
Messages
20
Okay I've searched and searched and can find lots of references to FileCopy, but none that suit my purpose and problem 100%

I'm setting up a "take the database home" script, which will enable my users to take the latest version of the database front end and the latest backend home with them, locking the current backend by setting its attributes to read-only for everyone in the office while someone has it at home. This all works fine as there is only one person working on any given backend at a time (each client has a different backend for one reason or another!)

Problem is there is a database of shared tables for each of these separate backends. I want the user to be able to take this home too. I'm simply using FileCopy as such:

Code:
FileCopy "S:\Databases\Bill_Verification_Tool\BillVerification_SharedTables.mdb", ToFile & "BillVerification_SharedTables.mdb"

(N.B. ToFile is the location they are copying to whether that be a laptop harddrive or a flash drive).

I'm getting a Run-Time Error '70' (oddly enough!) as the shared tables are ALWAYS in use. The data in the shared tables doesn't often change and in fact I envisioned setting the take home copy to read only so any changes the user makes MUST be done in the office. Is there any way to get around the "file is open, so you can't bloody have it" error? Perhaps an alternative to FileCopy? I've considered replication too, but thats a road I only want to go down as a last resort.
 
FYI:

As a workaround for now, I've written a batch file which copies the existing Shared database on the network map drive to another location, and then I'm using the VBA FileCopy command to copy the copy... it's long winded, but it works.
 
I know this is an old thread but I thought I would reply in case someone stumbled upon it like I did.

I have had a lot of luck using this windows API:

Public Declare Function CopyFile Lib "Kernel32" Alias "CopyFileA" (ByVal lpExistingFileName As String, ByVal lpNewFileName As String, ByVal bFailIfExists As Long) As Long
after the above is declared, you can call it like this:

CopyFile "S:\Databases\Bill_Verification_Tool\BillVerification_SharedTables.mdb", ToFile & "BillVerification_SharedTables.mdb", False
This code does not care if the file is in use. Hope this helps someone.
 

Users who are viewing this thread

Back
Top Bottom