Prefill txt box from drop down list code

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
5,832
Office Version
  1. 2007
Platform
  1. Windows
Evening all,

I am making a small userform & would like to ask for some help / assistance with its set up if i may.
Currently i am able to select an item from the drop down list & its image is shown but would like the following to be also included.

Database is as follows.
Column A = Item Number
Column E = Cost
Column F = Url to image

So when i make a selection from the drop down list i would like to also see the txt boxes mentioned in the code below filed with the info that will be in the cell from column A & E mentioned above.

You will also see there is a CommandButton2 of which when pressed would take me to the image on the Internet using the info from whats in the cell in column F


I have currently the code as shown below.

Code:
Option ExplicitPrivate Sub cmbImg_Change()
On Error Resume Next
Dim myImg
myImg = Me.cmbImg.List(Me.cmbImg.ListIndex, 2)
Me.Image1.Picture = LoadPicture(myImg)


Me.Label1 = Me.cmbImg.List(Me.cmbImg.ListIndex, 1)
End Sub


Private Sub CommandButton2_Click()


End Sub


Private Sub txtCost_Change()


End Sub


Private Sub txtItemNumber_Change()


End Sub
 
Trying to use your code but dont get any item numbers in the drop down list ??
 
Upvote 0

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Column then Text

A Item Number
B Description
C Path to image
D Image
E Cost
F Url

Range is A3:F43
 
Upvote 0
Sorted.
Using my own form and then using the code below works.

Code:
[COLOR=#333333] Image1.Picture = LoadPicture(ThisWorkbook.Path & "\" & ComboBox1.Value & ".jpg")[/COLOR]

Is there no way to have the photos in a different folder,why must it be in the same folder ??
 
Upvote 0
This is now correct many thanks.

Code:
Me.Image1.Picture = LoadPicture("C:\Users\Ian\Desktop\SKYPE\LOCK PICK ME\" & "\" & ComboBox1.Value & ".jpg")
 
Upvote 0

Forum statistics

Threads
1,224,827
Messages
6,181,200
Members
453,022
Latest member
RobertV1609

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top