Copy and/or rename files during an event

EPD Hater

Registered User.
Local time
Today, 14:07
Joined
Mar 30, 2003
Messages
50
Hello all. Basically, whenever a DoCmd.TransferText method is used, I would like to make a backup of the current file by copying it to a file which will be named depending on what the date is. For example, the file detail.txt will be created using the TransferText method, but prior to that, I want the existing file currently named detail.txt to be renamed/copied to 060403.txt [mmddyy.TXT format] which does not currently exist. Is this possible through an event procedure?

Thanks...
 
use code as follows:

Code:
If Len(Dir("c:\ExistingFile.txt")) > 0 Then
    'File exists so rename
    FileCopy "c:\ExistingFile.txt", "c:\" & Format(Date, "mmddyy") & ".txt"
    Kill "C:\ExistingFile.txt"
    MsgBox "File renamed successfully"
Else
    'File does not exist - Unable to rename
    MsgBox "File does not exist"
End If

HTH

Brad.
 
And you coded the whole thing out for me! Thank you very much. You are a big help. Now this opens new ideas on file handling within Access for me.
 

Users who are viewing this thread

Back
Top Bottom