Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FileCopy Problem

Status
Not open for further replies.

GPM4663

Technical User
Aug 9, 2001
165
GB
I have a database back end that sits on our server and the front end sits on each users desktop. Whenever I update the front end I place the new copy into a folder on the server. When a user opens their desktop front end a piece of code checks if the date/time of the front end on the server is more recent that the one on their desktop. If true, their front end automatically opens a small database, (then closes their Front end), that uses FileCopy source, target to copy the more recent front end onto the users desktop. I do it this way because it obviously won't let me copy a new file onto the desktop if the database is still open.

My problem is that everything was running well until we upgraded to office XP. I in turn upgraded all the database files to access 2002. Now the database goes through the procedure of copying a new version but it doesn't actually do it. I've stepped through the code with no problems and it carries out the FileCopy action but when I check the new front end it's actually still the old one? I've converted the mdb's back to 2000 but the problem still remains! Has anyone every seen anything like this before?
 
How about modifying your code so that it doesn't so much overwrite the existing front-end as replace it? The sequence of events would be:

1. Rename existing client front-end (e.g. change fe.mdb to fe.bak)
2. Copy server front-end to client
3. Check new client front-end exists (could perhaps use Dir() for this)
4. If so, delete fe.bak - otherwise, rename fe.bak to fe.mdb to restore old front-end

Helpful? [pc2]
 
mp9,

That actually makes a lot more sense than what I'm trying to do. What code should I use to rename the database to fe.bak?

Many thanks,

GPM
 
I haven't tested this but I'm guessing you'll want something like:

Code:
' Rename client front-end
FileCopy "c:\mydb\fe.mdb", "c:\mydb\fe.bak"
DoEvents
' Copy new front-end from server
FileCopy "f:\mydb\fe.mdb", "c:\mydb\fe.mdb"
DoEvents
' Check if copy has been successful
If Len(Dir("c:\mydb\fe.mdb")) > 0 Then
    ' If so, delete back-up
    Kill "c:\mydb\fe.bak"
Else
    ' If not, restore backup
    FileCopy "c:\mydb\fe.bak", "c:\mydb\fe.mdb"
End if
DoEvents
[pc2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top