Here are some suggestions:
Code:
Option Compare Database
Option Explicit
' Run Lista
' ============================================
Public Sub RunLista()
Me.Lista.ColumnHeads = True
Me.Lista.ColumnCount = 8
Me.Lista.ColumnWidths = "0in; 1,2in; 3in; 2in; 1in; 1,2in; 1in"
Me.Lista.RowSource = " SELECT Products.ID, Products.Qdate, Products.Code, Products.description FROM Products"
End Sub
Private Sub Form_Load()
Call RunLista
End Sub
Private Sub Lista_Click()
Call RefrechPicture
Err.Clear
End Sub
Private Sub RefrechPicture()
'Vlad the error 2220 is probably coming from this sub.
'first of all the Column collection of the listbox control is 0 based so Column(1) will be the Products.Qdate (the second column), I 'assume you probably want Column(2) which is the Products.Code
'https://learn.microsoft.com/en-us/office/vba/api/access.listbox.column
'then you cannot try to load all posible graphic extensions like you do here without some error handling, you should be consistent and 'use only one extension or add a loop and search for each one in order using Dir and exit the loop when found
'If Dir(Application.CurrentProject.Path & "\Picture\" & Me.Lista.Column(1) & ".jpg")="" Then 'the file doesn't exist, try the next 'extension
'On Error Resume Next
Me.ImagePicture.Picture = Application.CurrentProject.Path & "\Picture\" & Me.Lista.Column(1) & ".jpg"
Me.ImagePicture.Picture = Application.CurrentProject.Path & "\Picture\" & Me.Lista.Column(1) & ".bmp"
Me.ImagePicture.Picture = Application.CurrentProject.Path & "\Picture\" & Me.Lista.Column(1) & ".png"
Me.ImagePicture.Picture = Application.CurrentProject.Path & "\Picture\" & Me.Lista.Column(1) & ".ico"
Me.ImagePicture.Picture = Application.CurrentProject.Path & "\Picture\" & Me.Lista.Column(1) & ".gif"
Me.ImagePicture.Picture = Application.CurrentProject.Path & "\Picture\" & Me.Lista.Column(1) & ".jpeg"
End Sub
Cheers,