default image in userform

Carlit007

New Member
Joined
Sep 5, 2018
Messages
47
Office Version
  1. 2019
  2. 2016
  3. 2013
Platform
  1. Windows
  2. 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?


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
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,020
Messages
5,834,986
Members
430,331
Latest member
Syed Yasir Hannan

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
Top