Full Version: associating jpg images with records imported via dbf
UtterAccess Discussion Forums > Microsoft® Access > Access Automation
joncraver
I have a table imported from a .dbf file that contains around 3000 entries.
Each record represents one item in inventory by Item Number.

I also have a folder that contains .jpg files. These are images of most of the intentory items.
The image file names consist of the item number & .jpg

Is there any way to associate those images with the correct record (based on item number)
without adding them one at a time?

The table itself will be updated periodically from a new .dbf file. so the images would need to be in a seperate table.
Aquadevel
Jon,

You don't want the images 'within' the Access database because of causing the database size
to bloat big time.

You think you could use Hyperlink to grab the required image from a list to match your 'item number'.

Good luck, sad.gif

Aqua
rsindle
Personally, unless you have a really good reason for it, I'd leave the .jpgs in the file system and point to them from Access.
If they are all in 1 folder and the image file is always the Item number followed by .jpg
(i.e, Item number 1005 has a picture file on disk called 1005.jpg) then you can easily compute a reference to the picture as follows:

Assume the location of the pics is:

C:\Project1\Database\Images

Set up a variable

dim strPathName as string

strPathName = "C:\Project1\Database\Images\"


In the current event of any form that you might want to display the pics the location is:

dim strFullPath as string
strFullPath = strPathname & cstr(ID) & ".jpg"


(This assumes the ID number is an Integer)
If its a string use:

strFullPath = strPathname & IDNum & ".jpg"


ScottGem
They already ARE associated via the item Number. it is not recommended that you store the images in your database. If all the images are inthe same folder its easy to display them on a form using an unbound image control.

In the On Current event of your form use code like:

Me.imgItemPic.Picture="x:\\images\" & Me.txtitemNumber & ".jpg"



NoahP
I wouldn't hard code the path. Keep the image folder in the same folder as the database and use a relative path instead:

Dim strPath as String
strPath = CurrentProject.Path & "\" & Me.ItemNumber & ".jpg"

If Dir(strPath)<>"" then
Me.imgItem.Picture = strPath
Else
Me.imgItem.Picture = ""
End If

That checks to make sure the image exists before it links it to the image control. Air code and untested though.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.