erutherford
Active Member
- Joined
- Dec 19, 2016
- Messages
- 449
Trying to load an image into a form. I thought ListIndex would do the trick. Images are stored in the data table (MyCars) col. "O". The code creates an error "Object error"
any ideas?
thanks to all
Code:
Private Sub cbxdrpdwn_Change()
Dim lastrow As Long, ws As Worksheet
Dim ans As String
ans = Me.cbxdrpdwn.Value
Set ws = Sheets("MyCars")
lastrow = ws.Range("D" & Rows.Count).End(xlUp).Row
'***** Start Code
For i = 2 To lastrow
If ws.Cells(i, "D").Value = ans Then
MsgBox "Confirm" & Me.cbxdrpdwn.Value
'Change back to white after selection
Me.cbxdrpdwn.BackColor = vbWhite
Me.tbxYear = ws.Cells(i, "A").Value
Me.tbxMake = ws.Cells(i, "B").Value
Me.tbxModel = ws.Cells(i, "C").Value
Me.tbxLicense = ws.Cells(i, "E").Value
Me.tbxColor = ws.Cells(i, "F").Value
Me.tbxVIN = ws.Cells(i, "G").Value
Me.tbxpdate = ws.Cells(i, "H").Value
Me.tbxPAmt = ws.Cells(i, "I").Value
Me.tbxPAmt = Format(tbxPAmt, "$#,##0.00")
Me.tbxPMiles = ws.Cells(i, "J").Value
Me.obYes = ws.Cells(i, "L").Value
Me.obNo = ws.Cells(i, "M").Value
Me.Image2.Picture = LoadPicture(MyCars.List(MyCars.ListIndex, 14))
Me.TextBox2 = ws.Cells(i, "O").Value
Exit Sub
End If
Next i
End Sub
thanks to all