PDA

View Full Version : [SOLVED] Picture, changes with list selection



MUSASHI
11-02-2004, 12:52 PM
I have an employee list, named range "emplist". To view an employee I call a userform, it has a list box with various employee names....when I select employee I get the caption data, as well as a frame for a pic....I cant get the pic to show up...I been messing with this for a over an hour...shrugs

what the heck am I doing wrong...big things first, then little things..hah
:bore

Private Sub ListBox1_Click()
Dim EmpFound As Range
With Range("EmpList")
Set EmpFound = .Find(ListBox1.Value)
If EmpFound Is Nothing Then
Label1.Caption = ""
Else
With EmpFound
Label1.Caption = "LastName: " & .Value & vbLf & _
"FirstName: " & .Offset(, 1).Value & vbLf & _
"Position: " & .Offset(, 2).Value & vbLf & _
"Hired: " & .Offset(, 11).Value & vbLf & _
"DOB: " & .Offset(, 9).Value & vbLf & _
"SS#: " & .Offset(, 10).Value & vbLf & _
"Employee#: " & .Offset(, 13).Value & vbLf & _
"Phone: " & .Offset(, 7).Value
On Error Resume Next
Img_Employee.Picture = LoadPicture _
("C:\Documents and Settings\Dunlap\excelprojects\" & EmpFound & ".bmp")
On Error GoTo 0
End With
End If
End With
End Sub

the basic code came form Mr.Excel file...I added additional list items etc.

Thx!

Zack Barresse
11-02-2004, 01:14 PM
Hi,

This is what I use on a userform of mine ...


Private Sub ComboBox1_Change() 'Change the combobox picture
Dim fPath As String
fPath = ThisWorkbook.path & "\"
On Error Resume Next
Img_loc.Picture = LoadPicture(fPath & ComboBox1.Value & ".jpg")
If Err = 0 Then Exit Sub
Img_loc.Picture = LoadPicture(fPath & "helpicon.jpg")
End Sub


Img_Loc is the name of the Picture box. As you can see, it's for a ComboBox, but you shouldn't have any trouble transferring it to a ListBox ...

The 'helpicon.jpg' is a picture I have saved to the same directory (which this is defaulted to for all other pics) for those that don't match.

MUSASHI
11-02-2004, 05:42 PM
Thanks Fire!

I'll give it a try, you and DRJ stick with me, I will get better!!! (I hope..heheh)

Thx a lot, appreciate the time/help.




Worked, after a little hammer....err I mean massaging..:*)

Zack Barresse
11-03-2004, 09:06 AM
Well we will stick with you if you stick with us. ;) LOL!

Hope that helped. Post back if necessary. Take care. :)