FileCopy Problem

  • Thread starter Thread starter Josie
  • Start date Start date
J

Josie

Can someone tell why this code does not work:

Dim FromDir As String, ToDir As String
Dim Source As String, Target As String

ToDir = DLookup("PropertyPath", "MyFirm")
FromDir = DLookup("PhotoPath", "MyFirm")

Source = FromDir & "\test.jpg"
MsgBox Source - folder & file name shows correct

Target = ToDir & "\test.jpg"
MsgBox Target - folder & file name shows correct

FileCopy Source, Target

Nothing is copied

Thanks in advance

Josie
 
Josie,

The code below worked fine:

Private Function CopyMyFile()
Dim FromDir As String, ToDir As String
Dim Source As String, Target As String
FromDir = "C:\Test1"
ToDir = "C:\Test2"
Source = FromDir & "\1.bmp"
Target = ToDir & "\1.bmp"
FileCopy Source, Target
End Function

I can only assume that you have the directories the wrong
way round in your lookup table

Alastair
 
Alister

Thanks for the suggestion, re-looked at my code and found
that my code for the To folder was incorrect - the file
was always being copied - but into another folder!!

Josie
Had the code
 
Back
Top