Carlit007
New Member
- Joined
- Sep 5, 2018
- Messages
- 47
- Office Version
- 2019
- 2016
- 2013
- Platform
- Windows
- MacOS
Hi I have a user-form with the following attributes
CBserial is a s dropdown list that populates from a worksheet called "LocationData"
TextBox2 1 is textbox that gets populated from the value on the dropdown list above
Image2 is a placeholder for the product images
currently the image in Image2 changes according to the item listed in TextBox2 1 pretty much the Stock number that is linked to cell range in column B.
Note:
1.) all images are located in a folder named "images" currently located on my desktop
2.) the filenames are .jpg images match the product name in column B
is there a way to point to an image that is a placeholder (kinda like the yearbook picture not available)
in other way what is the easiest way whats the easier way to declare a default image for a user form image field when no data is available?
CBserial is a s dropdown list that populates from a worksheet called "LocationData"
TextBox2 1 is textbox that gets populated from the value on the dropdown list above
Image2 is a placeholder for the product images
currently the image in Image2 changes according to the item listed in TextBox2 1 pretty much the Stock number that is linked to cell range in column B.
Note:
1.) all images are located in a folder named "images" currently located on my desktop
2.) the filenames are .jpg images match the product name in column B
is there a way to point to an image that is a placeholder (kinda like the yearbook picture not available)
in other way what is the easiest way whats the easier way to declare a default image for a user form image field when no data is available?
VBA Code:
Private Sub CBserial_Change()
On Error Resume Next
'If CBserial.ListIndex <> "" Then
'Else
'Image2.Picture = LoadPicture(ThisWorkbook.Path & "\Images\default.jpg") "<----------this code I tried with no sucess"
'End If
Dim f As Range
TextBox1.Value = ""
TextBox2.Value = ""
TextBox3.Value = ""
TextBox4.Value = ""
TextBox5.Value = ""
TextBox6.Value = ""
TextBox7.Value = ""
TextBox8.Value = ""
TextBox9.Value = ""
TextBox10.Value = ""
TextBox11.Value = Date + Time
If CBserial.ListIndex > -1 Then
With Sheets("LocationData")
Set f = .Range("MasterSerial").Find(CBserial, , xlValues, xlWhole)
If Not f Is Nothing Then
TextBox1.Value = .Cells(f.Row, 2) 'LIN
TextBox2.Value = .Cells(f.Row, 3) 'MATERIAL #
TextBox3.Value = .Cells(f.Row, 4) 'ADMIN #
TextBox4.Value = .Cells(f.Row, 5) 'DESCRYPTION
TextBox5.Value = .Cells(f.Row, 6) 'SECTION
TextBox6.Value = .Cells(f.Row, 7) 'ROOM
TextBox7.Value = .Cells(f.Row, 8) 'DESK/SHELF
TextBox8.Value = .Cells(f.Row, 9) 'LOCATION
TextBox9.Value = .Cells(f.Row, 10) 'SLOC
TextBox10.Value = .Cells(f.Row, 11) 'Signed by
TextBox11.Value = .Cells(f.Row, 12) 'dTE
Me.Image2.Picture = LoadPicture(ThisWorkbook.Path & "\Images\" & TextBox2.Value & ".jpg")
Else
MsgBox "Dont exists"
End If
End With
End If
End Sub