Image Based on Combo Box Selection

J

jjones

I am creating a database (’97) with 2 tables, “Master Table†and “Equipment
Types†that will basically serve as an inventory control system. The Master
Table will contain information about equipment that we loan out (i.e. serial
numbers, date sent out, etc.) I have created a form based on the Master Table
and on that form I have a drop-down/combo box based on the equipment table.
What I would like to do is have an image displayed on the form of the piece
of equipment that is selected in the combo box. I’ve been reading through
the posts on these message boards and I see the repeated warnings about
bloating the database by embedding the actual picture files into the database
(not that I can figure out how to pull this off either way). Heeding that
bit of advice though I went ahead and set up a folder on our shared network
drive to contain all the pictures that I will need. Then I went back into my
equipment table and added a text field called “ImagePathâ€, so by each type of
equipment in the equipment table there is now a link that goes back to the
corresponding picture of that piece of equipment. I went back to my form and
played around with inserting an image control but I don’t really know what
I’m doing. How do I essentially tie it to my combo box so that whatever is
selected changes the picture (or can this even be done)?


PS – My apologies for posting this on the general board…just wasn’t sure
which of the others to put it on.
 
A

Arvin Meyer [MVP]

I have a demo that shows how to link the image to a record.

http://www.datastrat.com/Download/Picture2K.zip

Use the after update event og the combo box to change the picture property
(sample code):

Sub MyCombo_AfterUdate()
Me.ImageControlName.Picture = Me.MyCombo.Column(2)
End Sub

where MyCombo.Column(2) is the third column (width set to zero) of your
combo box and containing the path to the image file.
 
F

Fred

The earlier part of your question was a bit confusing. Your descriptions
make it sound like you have already sucessfully gotten the image path
(presumably path and file name) loaded into the field. (So, then, what
is the combo box doing?)

If so, then previous posts on this tell you how to make it show in the form.
I'm not good enough to just describe it from memory, but I think that you
just put in a sourceless "bound" control (box) for the picture (let's say
it's name is "ImageBox") and then put code like the following into the
"OnCurrent" event of the form:

Me.ImageBox.Picture = Me.PicturePathAndFile

("PicturePathAndFile" is the name of the field with the picture path and
file name in it)

Being a dummy on this probably makes me better at explaining it, but don't
trust my answer as being expert on the details

Hope that helps a little.

Sincerley,

Fred
 
J

jjones

Beautiful. Thanks, Arvin!!!!!!!!

Arvin Meyer said:
I have a demo that shows how to link the image to a record.

http://www.datastrat.com/Download/Picture2K.zip

Use the after update event og the combo box to change the picture property
(sample code):

Sub MyCombo_AfterUdate()
Me.ImageControlName.Picture = Me.MyCombo.Column(2)
End Sub

where MyCombo.Column(2) is the third column (width set to zero) of your
combo box and containing the path to the image file.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com
 

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