Hello,
It is 2am on a Sunday so please be nice.
The form has a txtOriginalFile control. This is a hyperlink to a file at it's original location\folder.
The record source's PK is in control txtMyPK.
The following code works as expected and copies the file to the destination folder (myFolder).
I need help with this part:
Original file = C:\Folder_A\myFile.pdf
Destination = C:\Folder_B\321_myFile.pdf (where 321 is the PK + underscore).
Please help.
Thank you,
Jamie
It is 2am on a Sunday so please be nice.
The form has a txtOriginalFile control. This is a hyperlink to a file at it's original location\folder.
The record source's PK is in control txtMyPK.
The following code works as expected and copies the file to the destination folder (myFolder).
I need help with this part:
Original file = C:\Folder_A\myFile.pdf
Destination = C:\Folder_B\321_myFile.pdf (where 321 is the PK + underscore).
Code:
Private Sub btnCopyFile_Click()
Dim myFilePath 'original file
Dim myFolder ' destination folder
myFolder = "C:\Folder_B\"
Set FSO = CreateObject("Scripting.FilesystemObject")
myFilePath = Me.txtOriginalFile
'here i was thinking something like:
'myFilePath = Me.txtMyPK & "_" & Me.txtOriginalFile
'but ofcourse then i get:
'321_C:\Folder_A\myFile.pdf
If FSO.FileExists(myFilePath) Then 'overwrite
FSO.CopyFile myFilePath, myFolder, True
End If
End Sub
Please help.
Thank you,
Jamie