VBA code to insert 1000 jpg

  • Thread starter Thread starter Margaret
  • Start date Start date
M

Margaret

Help! Does anyone know of some tips or source code to
help me insert over 1000 .jpg file names in the an OLE
field in my Access table? I have a Parts table with a
PartID. The .jpg file has the part id as the file name
i.e. SD1234.jpg for part S1234.

Thanks
Margaret
 
My tip would be - don't!

The general opinion in these groups is that Access is rubbish for storing
image files. It's much better to store information on the location of the
file in the database (in a text field), and then use a bit of VBA code to
display the image when needed.

In your case you don't even need to store the file name as you have used a
naming system for your images that matches the part number that is already
in your database. Assuming the files are all in the same place, then you
already have everything in place as far as the database goes.

Try creating a form that is bound to the table containing your part codes.
Add a text box showing the partid and an image control. Then add some code
to the current event of the form along the lines of:

Dim strFileName as String

strFileName = "C:\NameOfImageDirectory\" & [PartID] & ".jpg"
Me.NameOfImageControl.Picture = strFileName

This technique won't work for continuous forms - you'll see the same image
in each record. However it should work OK in reports using the format event
for the code.
 
Thanks for the quick response - I will try it. Have a
great weekend.

Margaret
-----Original Message-----
My tip would be - don't!

The general opinion in these groups is that Access is rubbish for storing
image files. It's much better to store information on the location of the
file in the database (in a text field), and then use a bit of VBA code to
display the image when needed.

In your case you don't even need to store the file name as you have used a
naming system for your images that matches the part number that is already
in your database. Assuming the files are all in the same place, then you
already have everything in place as far as the database goes.

Try creating a form that is bound to the table containing your part codes.
Add a text box showing the partid and an image control. Then add some code
to the current event of the form along the lines of:

Dim strFileName as String

strFileName = "C:\NameOfImageDirectory\" & [PartID] & ".jpg"
Me.NameOfImageControl.Picture = strFileName

This technique won't work for continuous forms - you'll see the same image
in each record. However it should work OK in reports using the format event
for the code.

Margaret said:
Help! Does anyone know of some tips or source code to
help me insert over 1000 .jpg file names in the an OLE
field in my Access table? I have a Parts table with a
PartID. The .jpg file has the part id as the file name
i.e. SD1234.jpg for part S1234.

Thanks
Margaret


.
 
Back
Top