Need Help!

momoko

Registered User.
Local time
Today, 10:16
Joined
Oct 7, 2001
Messages
41
Hi,

I have a code below that does a filecopy from a network drive to my local harddisk. Each time when there is a new file I will have to add on to the code. How can I keep the directory and file name into a table a make the program read each records and filecopy them to c:\? instead of having to keep adding the code?


Fund10a = "G:\Funds\test\"
Fund10b = "c:\temp\"
PDF10 = "\test.pdf"

Fund10a = "G:\Funds\test\" & PDF10
FileCopy Fund10a, Fund10b & PDF10
 
Do you mean you wish to have a table with all you filenames and the code uses that table to copy the files? If so then try this (Access 97 only - I've heard that the below code wont work in Access 2000) :

I assume that your Table with the Filenames is called [Files] and you field containing your filenames is called [Filename]

Code:
Dim Rst as RecordSet
Dim Db as Database
Dim Fund10a, Fund10b as String

Fund10a = "G:\Funds\test\" 
Fund10b = "C:\temp\" 

Set Rst = Db.OpenRecordset(Files, OpenDynaset)

With Rst
   .MoveFirst

   While Not Rst.EOF
      FileCopy Fund10a & !FileName, Fund10b 
      .MoveNext
   Wend

   .Close
End With
 
Thanks a zillion, this is what I'm looking for.
 

Users who are viewing this thread

Back
Top Bottom