Hello,
I'm trying to rename and move a file based on information in fields. I have tried FileCopy with
Code:
Private Sub FileRename_Click()
Dim OldName As String
Dim NewName As String
OldName = "\\SERVER\Test.mp3"
NewName = "\\SERVER\Files\Patients\" & [Patient] & "\" & [Patient] & "_" & [File Type] & "_" & [Date] & "_" & [Accession Number] & ".mp3"
FileCopy OldName, NewName
End Sub
and with pkstormy's moveafile module found here: https://www.accessforums.net/program...lder-7588.html
Code:
Function MoveAFile(OldName as variant, NewName as variant)
if isnull(OldName) or isnull(NewName) then
msgbox "Old or New Folder/File name not supplied to function."
exit function
end if
retval = 0
Dim objFSO As Object
Set objFSO = CreateObject("Scripting.FileSystemObject")
retval = objFSO.CopyFile(OldName, NewName, True)
Set objFSO = Nothing
msgbox "File has been moved."
End Function
with
Call MoveAFile("\\SERVER\Test.mp3", "\\SERVER\Files\Patients\" & [Patient] & "\" & [Patient] & "_" & [File Type] & "_" & [Date] & "_" & [Accession Number] & ".mp3")
but both don't seem to work and both paths are valid but returns with Run-time error '438'. I've checked and the format of the FileCopy are similar to the one listed by Microsoft at: http://support.microsoft.com/kb/237273
Can anyone help?