Trouble with Recordset

J

junk

I don't work with this everyday and can't remember how to get the value
of the current record in a recordset. The recordset is one field from
a table which contains filenames, I need to compare each filename in
the recordset to all the files in a particular directory. If the
filename in the database does not exist in the directory I create a new
standard file by that name. I think I've got everything but how to get
the value to compare from the current record. This has got to be
simple right? I can't believe I couldn't find this in the access help
or searchs. But everything seemed to be going the opposite direction
seeing if a value was in a recordset. I need to do the opposite. The
code is below {{{{{{{{{THIS IS WHERE I NEED THE VALUE}}}}}}}}}.

Function createimages()
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim strWhereClause As String
strDirFilenameCompare = ""
Set db = CurrentDb

Path = "E:\My Documents\Scuba Steve's Documents\Wynit Distribution
Files\Product Images Desc PDFs\test"
NoImageFile = "E:\My Documents\Scuba Steve's Documents\Wynit
Distribution Files\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
' Get record set of database image names
Set rst = db.OpenRecordset("SELECT
tbl_master_pricing.v_products_image FROM tbl_master_pricing;")
rst.MoveFirst
strDirFilenameCompare = ""
v_image_file = {{{{{{{{{{{{VALUE OF CURRENT RECORD}}}}}}}}}}}
NewFile = Path & "\" & v_image_file
' Set flag to creat a new file
CreateFile = 1
Do Until rst.EOF
' Compare Database image name to all files in directory to see if it
exists
For Counter = 1 To Application.FileSearch.FoundFiles.Count
file = Application.FileSearch.FoundFiles.Item(Counter)
strDirFilenameCompare =
Trim((Mid(Application.FileSearch.FoundFiles.Item(Counter), 96, 50)))
If v_image_file = strDirFilenameCompare Then CreateFile = 0
Next
' If Database image name does not exist create a copy of the
no_image.jpg for the item
If CreateFile = 1 Then FileCopy NoImageFile, NewFile And FileCreate
= FileCreate + 1 Else MsgBox "No Image Created"
' Reset Variables and loop to next record
Set CreateFile = 1
rst.MoveNext
v_image_file = {{{{{{{{{{{{VALUE OF CURRENT RECORD}}}}}}}}}}}
NewFile = Path & "\" & v_image_file
strDirFilenameCompare = ""
Loop
rst.Close
MsgBox (FileCreate & " files created.")
End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top