Results 1 to 3 of 3

Thread: By pass Error Message '53' File not found

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    By pass Error Message '53' File not found

    I wrote a Module in access that will analized a particular column in a table in my case is "Part No" and then it searches for the image matching the part number and copies it and pastes it in a designated folder. The problem I'm facing is that if there is not a picture the function will give me an error '53' file not found and then exits the code. I found some info about error handling but no luck. Any help will be appreciated. Thank you in advance.


    Here is my CODE.



    Option Compare Database
    Option Explicit
    
    
    Function CCSImageLookup()
    
    
    Dim rst As Recordset
    Dim fs As Object
    Dim oldPath As String, newPath As String
    
    
    Set rst = CurrentDb.OpenRecordset("SELECT trim(CCS_PartsLookUp.[Part No]) as [Part No]" _
    & " FROM CCS_PartsLookUp")
    
    
    While Not rst.EOF
    oldPath = "T:" 'Folder file is located in
    newPath = "C:\Users\Desktop\Pictures"                               'Folder to copy file to
    Set fs = CreateObject("Scripting.FileSystemObject")
    'MsgBox rst![Part No] & ".jpg"
    fs.CopyFile oldPath & "\" & rst![Part No] & ".jpg", newPath & "\" & rst![Part No] & ".jpg"     '<---- this is the line where the error happens if it does not find  
    Set fs = Nothing                                                                                                     '--matching Part No.
    rst.MoveNext
    
    
    Wend
    
    
    End Function
    Last edited by Bob Phillips; 06-06-2014 at 08:51 AM. Reason: Added VBA tags

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •