Results 1 to 11 of 11
  1. #1
    Join Date
    Feb 2025
    Posts
    9

    error 2220


    Good evening
    When running the list how can I display the images without getting error 2220
    thanks
    Attached Files Attached Files

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556
    And 220 is?
    Do not make us go looking for it.

    Edit: I get the attached, and it is all Greek to me. so I am out.
    Attached Thumbnails Attached Thumbnails Greek.png  
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    Join Date
    Feb 2025
    Posts
    9
    sorry,
    I'm uploading it corrected
    Attached Files Attached Files

  4. #4
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2013 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,250
    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,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  5. #5
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556
    I am getting the attached even when I comment out the load code?
    Attached Thumbnails Attached Thumbnails Screenshot 2025-03-09 130013.png  
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  6. #6
    Join Date
    Feb 2025
    Posts
    9
    Thank you very much

  7. #7
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2013 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,250
    @Welshgasman: try to remove the control source for the image control.
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  8. #8
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556
    Quote Originally Posted by Gicu View Post
    @Welshgasman: try to remove the control source for the image control.
    Nope, still get the error. I will leave it in your capable hands.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  9. #9
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2013 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,250
    Do you still get that error in this file?
    Attached Files Attached Files
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  10. #10
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556
    No, but get an empty form.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  11. #11
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2013 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,250
    Because is unbound, I think it was intended to act as an image browser.
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Gett Error 2220 when try to add an image
    By Dave14867 in forum Forms
    Replies: 4
    Last Post: 10-06-2020, 01:14 AM
  2. Replies: 1
    Last Post: 11-28-2014, 06:56 PM
  3. Replies: 3
    Last Post: 01-23-2014, 07:49 AM
  4. Intercepting error codes like 2220, file not found
    By justphilip2003 in forum Programming
    Replies: 4
    Last Post: 04-21-2013, 11:33 AM
  5. Replies: 0
    Last Post: 07-16-2012, 05:42 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums