Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Linking Pictures 2

Status
Not open for further replies.

ChrisBair

Technical User
Mar 17, 2004
32
US
I have a Employee Database. How do I link the Drop Dowm Combo box to display the cooresponding images? Have the pictures in the same folder as the access database.

Thanks
 
- So what does the combo box contain ?

If it is the file name of the picture file then I tend to do the following

Add a field to your SetUp table called PhotoRoot and set it to the "\\server\path\folder\" where the photos are

This gives you the flexibility of being able to have the pics and the db in different places at any time in the future

Then at startup set gstrPhotoRoot = contents of PhotoRoot field


Then in code

Private Sub cboPicPhoto_AfterUpdate()
picBoxControl.Picture = gstrPotoRoot & cboPicPhoto
End Sub



'ope-that-'elps.



G LS
spsinkNOJUNK@yahoo.co.uk
Remove the NOJUNK to use.
 
and how from the name of the employee do you want to find the picture? Is there a field that stores the path or file name?

Leslie
 
By either employee name(which is in the combo box) or linked to employee ID# (1-4)
Table "Employee"
There isnt a field

 
So, you have a combo box with the following employees:

Robert Jordan
Terry Goodkind
Melanie Rawn

you have pictures of these people stored in the same directory.

The user selects Robert Jordan, how do you find his picture? Is it name RobertJordan.gif, or Emp#1.gif, or what? How can you determine which picture to retrieve based the selection?

Leslie
 
The images are not linked to the specific employee, that is what i am trying to figure out.

Should I create a field in the table linking to the Path

Thanks
 
Add a field to the tblEmployee called PictureName and place the file name of that employee's picture in there

( Use the Common Open/Save dialog to allow Admin user to obtain this from the folder of pictures in the first place )

Then use the combination of Root & FileName as described in the post above.



'ope-that-'elps.



G LS
spsinkNOJUNK@yahoo.co.uk
Remove the NOJUNK to use.
 
LittleSmudge and lespaul have given you all the right techniques to do what you want. The decision that you have to make now is how to name your photos. It is recommended that you name with some unqiue identification that is already found in the employees record. Something that is not going to change. EmployeeID, Name(Last,First), etc. This way you don't have to add a new field for the picture name.

The RowSource of your ComboBox can include an additional column that may or may not be visibile that holds this unique identifier. You would access this column with the use of the .column property of the ComboBox:

Code:
Select A.LastName & ", " & A.FirstName as Name, A.ID FROM Employee as A ORDER BY (A.LastName & ", " & A.FirstName);

With your combobox setup with 2 columns with column widths set to 3;0 you can now reference the ID column with the .column property(using LittleSmudge's example:

Code:
Private Sub cboPicPhoto_AfterUpdate()
picBoxControl.Picture = gstrPotoRoot & cboPicPhoto[red].column(1) & ".jpg"[/red]
End Sub

By naming all of the pictures as the employee ID plus ".jpg" and storing them in the target folder the above code should do the trick.

Post back if you have further questions.

[COLOR=006633]Bob Scriver[/color]
MIState1.gif
[COLOR=white 006633]MSU Spartan[/color]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top