Here is where I'm at this will all work if I could remember/figure out how to return the value of the recordset for comparison. The red text is the only part I think I'm lacking and for the life of me can't find what I'm looking for. Maybe it's lack of sleep.
Function createimages()
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim strWhereClause As String
strDirFilenameCompare = ""
Set db = CurrentDb
Path = "E:\My Documents\Product Images Desc PDFs\test"
NoImageFile = "E:\My Documents\Product Images Desc PDFs\test\NO_IMAGE.jpg"
With Application.FileSearch
.LookIn = Path
.SearchSubFolders = False
.fileName = "*.jpg"
.Execute msoSortByFileName
End With
If Application.FileSearch.FoundFiles.Count = 0 Then
MsgBox "No Files Found"
Exit Function
End If
Set rst = db.OpenRecordset("SELECT tbl_master_pricing.v_products_image FROM tbl_master_pricing;")
rst.MoveFirst
strDirFilenameCompare = ""
image_file_rec =
CURRENT RECORD IN RECORDSET
NewFile = Path & "\" & image_file_rec
CreateFile = 1
For Counter = 1 To Application.FileSearch.FoundFiles.Count
file = Application.FileSearch.FoundFiles.Item(Counter)
strDirFilenameCompare = Trim((Mid(Application.FileSearch.FoundFiles.Item(C ounter), 96, 50)))
If image_file_rec = strDirFilenameCompare Then CreateFile = 0
Next
If CreateFile = 1 Then FileCopy NoImageFile, NewFile And FileCreate = FileCreate + 1 Else MsgBox "No Image Created"
rst.MoveNext
rst.Close
MsgBox (FileCreate & " files created.")
End Function
Neil