Results 1 to 3 of 3
  1. #1
    desk4tbc is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2011
    Posts
    29

    Copying and Rename of Files based on fields

    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?

  2. #2
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    what does "don't seem to work" mean? too vague...

    by the way, I like pkStormy, but messing around with the FSO when all you want to do is move or copy files is way too much work. see here for more info: https://www.accessforums.net/code-re...ing-14596.html

  3. #3
    desk4tbc is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2011
    Posts
    29
    Figured it out. Access didn't like me naming the data source and the field the same thing. I don't know why as I didn't put any reference to the source, but there you go.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Copying multiple files?
    By daveofgv in forum Programming
    Replies: 3
    Last Post: 04-14-2011, 03:18 PM
  2. Replies: 0
    Last Post: 02-25-2011, 09:40 AM
  3. Replies: 1
    Last Post: 02-21-2011, 09:55 PM
  4. Copying selected fields to a new record
    By Lyle Bitikofer in forum Forms
    Replies: 0
    Last Post: 12-13-2009, 04:01 PM
  5. Copying into empty fields until...
    By cochi30 in forum Programming
    Replies: 8
    Last Post: 06-07-2009, 07:38 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums