Change image in UserForm

J

Joseph

I want to create a userform with a listbox that has 4 columns, one
column is Customer#. Each item in the list will have a related picture
of the same name (i.e. Customer# 01234 = X:\Pictures\01234.jpg) stored
in a folder on my computer.

Is it possible to have the Image control on the userform updated 'when
the item in the list is selected' rather than having to click on a
command button, so that each time you would select an item in the list,
the image on the userform would change?

Thanks,
Joe
 
T

Tom Ogilvy

Private Sub Listbox1_Click()
if listbox1.ListIndex <> -1 then
Image1.Picuture = loadPicture( _
"X:\Pictures\" & Listbo1.Value & ".jpg")
end if
End Sub

Depends on what the value of Listbox1 is. Here, I assume it is the name of
the picture (Customer#). Set the customer# column as the BoundColumn for
the listbox.
 

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