junior6202
07-08-2014, 12:14 PM
I wrote this code to search a particular column in access and find the matching picture from a different drive. Which works perfectly, now my results gave me 476 pictures found and were store in a folder I called HFPics, the problem is that the access file shows there are 495 pic so obviously there are 19 pics missing. I want to write a function or add to the code i already have that takes the column in access and checks the picture number against the folder and returns the missing picture numbers that are missing or don't match.
Function ImageLookup()
Dim rst As Recordset
Dim fs As Object
Dim oldPath As String, newPath As String
Set rst = CurrentDb.OpenRecordset("SELECT Hunter_Fan_Images.[Item Number] As [Part No]" _
& " FROM Hunter_Fan_Images")
Set fs = CreateObject("Scripting.FileSystemObject")
While Not rst.EOF
oldPath = "\\intranet\intranet2\Repairs\images" 'Folder file is located in
newPath = "C:\Users\EReyes\Desktop\HFPics" 'Folder to copy file to
'MsgBox rst![Part No] & ".jpg"
If Dir(oldPath & "\" & rst![Part No] & ".jpg") <> "" Then fs.CopyFile oldPath & "\" & rst![Part No] & ".jpg", newPath & "\" & rst![Part No] & ".jpg"
rst.MoveNext
Wend
Set fs = Nothing '--matching Part No.
End Function
Function ImageLookup()
Dim rst As Recordset
Dim fs As Object
Dim oldPath As String, newPath As String
Set rst = CurrentDb.OpenRecordset("SELECT Hunter_Fan_Images.[Item Number] As [Part No]" _
& " FROM Hunter_Fan_Images")
Set fs = CreateObject("Scripting.FileSystemObject")
While Not rst.EOF
oldPath = "\\intranet\intranet2\Repairs\images" 'Folder file is located in
newPath = "C:\Users\EReyes\Desktop\HFPics" 'Folder to copy file to
'MsgBox rst![Part No] & ".jpg"
If Dir(oldPath & "\" & rst![Part No] & ".jpg") <> "" Then fs.CopyFile oldPath & "\" & rst![Part No] & ".jpg", newPath & "\" & rst![Part No] & ".jpg"
rst.MoveNext
Wend
Set fs = Nothing '--matching Part No.
End Function