I know I have had this working, but for some reason I cannot get this code to work. I am trying to copy datafiles to a USB drive. It will make the folder, I can copy a small file to it using this code (see the copy of the wsca.ico file) to the folder on the USB. But when it comes to copying the datafiles I get this error: "copyfile IFileSystem3 2147024784"
I am working in A2003, but I have compiled it with A2000 to an MDE. If that is the problem, then why when I take the uncompiled file back to A2003 does it give me the same error now.
Also this works fine if I choose to do this to c:, but not the usb drives now. I have tried 3 different brands of USB drives, I have tried 4 different computers.
I know this worked before I compiled it, because I have the folders with the files on a USB drive.
Here's my Code:
'me.floc is a field on the form, by default it's set to c:\wsca
'me.cmbDr is a drop down that you select what drive letter to write to
Set fso = CreateObject("Scripting.FileSystemObject")
Dim strTo, strFrom
strFrom = Me.Floc & "\*_db.mdb"
strTo = Me.cmbDr & "\CEBU" & Format(Now(), "mmddyy") & "\"
strTo2 = strTo
Do While Len(Dir(strTo2, vbDirectory)) <> 0
'creates a unique folder each time it is run - works great
d1 = d1 + 1
strTo2 = Left(strTo, Len(strTo) - 1) & "_" & d1 & "\"
Loop
MkDir (strTo2)
strTo = strTo2
fso.copyfile strFrom, strTo
...
There is more to my code, but it doesn't ever get to it. I also have it using the fso.getfolder to list the files that it backedup.
I am working in A2003, but I have compiled it with A2000 to an MDE. If that is the problem, then why when I take the uncompiled file back to A2003 does it give me the same error now.
Also this works fine if I choose to do this to c:, but not the usb drives now. I have tried 3 different brands of USB drives, I have tried 4 different computers.
I know this worked before I compiled it, because I have the folders with the files on a USB drive.
Here's my Code:
'me.floc is a field on the form, by default it's set to c:\wsca
'me.cmbDr is a drop down that you select what drive letter to write to
Set fso = CreateObject("Scripting.FileSystemObject")
Dim strTo, strFrom
strFrom = Me.Floc & "\*_db.mdb"
strTo = Me.cmbDr & "\CEBU" & Format(Now(), "mmddyy") & "\"
strTo2 = strTo
Do While Len(Dir(strTo2, vbDirectory)) <> 0
'creates a unique folder each time it is run - works great
d1 = d1 + 1
strTo2 = Left(strTo, Len(strTo) - 1) & "_" & d1 & "\"
Loop
MkDir (strTo2)
strTo = strTo2
fso.copyfile strFrom, strTo
...
There is more to my code, but it doesn't ever get to it. I also have it using the fso.getfolder to list the files that it backedup.