Ms Access

J

Jimbob62

I have a table where I want to match up product names with a .jpg picture of
the product. All the .jpg product picture files are in a folder on my hard
drive
Using VBA is there any way to read the name of each .jpg file in the folder
and place the file name in one of the table fields (Image). I would want to
iterate over all the files in the folder and place all the file names in the
table (one record each). Of course I still have to relate the field
"Product_Name" to Image so that the correct picture is displayed, but let's
assume that that can be done. I now want to be able to just extract the file
name from the folder to place in the table and form
 
J

Jack MacDonald

Yes - the Dir() function will retrieve the names of the files in the
nominated folder. You can use the value it returns in an SQL statement
to INSERT the name into your table.

- aircode from memory - syntax may be wrong but you get the idea -

sFileName = Dir("myFolder\*.jpg")
do while len(sfilename) > 0
ssql = "insert into myTable (filefield) values (" & sfilename & ")"
currentdb.execute ssql
sfilename = dir()
loop


I have a table where I want to match up product names with a .jpg picture of
the product. All the .jpg product picture files are in a folder on my hard
drive
Using VBA is there any way to read the name of each .jpg file in the folder
and place the file name in one of the table fields (Image). I would want to
iterate over all the files in the folder and place all the file names in the
table (one record each). Of course I still have to relate the field
"Product_Name" to Image so that the correct picture is displayed, but let's
assume that that can be done. I now want to be able to just extract the file
name from the folder to place in the table and form


**********************
(e-mail address removed)
remove uppercase letters for true email
http://www.geocities.com/jacksonmacd/ for info on MS Access security
 

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