Page 1 of 2 12 LastLast
Results 1 to 15 of 23
  1. #1
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919

    Access fails to set a image control

    I have a popup form that contains an image control. The OnOpen code attempts to assign a jpg file as the picture property but fails with a message that Access can't find the picture.



    Code:
    Me.imgFormImage.Picture = DefaultImage
    I've examined the "DefaultImage" string to verify the fully qualified path to the file. If I assign that same file via the browse in the control property sheet Access has no problem.

    Click image for larger version. 

Name:	000.jpg 
Views:	21 
Size:	23.6 KB 
ID:	44319

    Any ideas why the Assignment statement shown above would fail?

  2. #2
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    Try moving it to the on load event.

    The controls / recordset aren't loaded at open.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  3. #3
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    I've graduated to the famous "2220 - Can't Open"
    Click image for larger version. 

Name:	001.jpg 
Views:	18 
Size:	18.5 KB 
ID:	44321Click image for larger version. 

Name:	000.jpg 
Views:	18 
Size:	42.9 KB 
ID:	44322

    I created a BMP version of DefaultPic and set the Picture property without any errors. I can only assume that Access is having difficulty with rendering a jpg file? I still need to find a solution to this caper, as there will be follow-on code that will need to change the picture per a user request.

  4. #4
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,803
    Open will work - the image control isn't bound so it's not loading anything. Setting any control or form property on Open should work.
    There is likely something wrong with your string or the variable that contains it.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    DefaultImage is Dim'd As String
    Here's the OPEN code that sets the string, folder locations being obtained from the app's settings. The string appears correct when viewed in Debug.
    Click image for larger version. 

Name:	002.jpg 
Views:	18 
Size:	100.3 KB 
ID:	44323

    Same error even if I eliminate any question about the string variable.
    Click image for larger version. 

Name:	003.jpg 
Views:	17 
Size:	109.7 KB 
ID:	44324

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Try using ControlSource instead of Picture property.

    I've never used Picture property for dynamic display of image.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,943
    I have to ask?

    Why set a control to it's default on Load of the form?

    I can only see those properties in the picture for a form in 2007 and not a control?
    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

  8. #8
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,803
    Picture property OnOpen works fine for me.
    ControlSource is for bound fields. Modifying the displayed picture (which is what starting with a default suggests will happen) has to mean the control is not bound IMO.
    I have to agree with Welshgasman - why isn't the 'default' just set as the picture path (linked) in design view?
    Last edited by Micron; 02-20-2021 at 11:05 AM. Reason: added info
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  9. #9
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    Not exactly sure what you're suggesting, as there isn't any ControlSource property revealed with "Me.imgFormImage."

  10. #10
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,803
    Yes, there is. Data tab.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  11. #11
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    I have to agree with Welshgasman - why isn't the 'default' just set as the picture path (linked) in design view?
    Only because the app's folder settings are subject to change.

  12. #12
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,943
    I am just trying it for the form background and am getting the same error

    OK, I have just got it to work but as far as I can see I just copied the path which just amended the case?

    Code:
    Private Sub Form_Load()
    Dim DefaultImage As String
    DefaultImage = "C:\Users\Paul\Pictures\Driving Licence.jpg"
    Me.Picture = DefaultImage
    End Sub
    Picture was Dirty boilersuits.jpg
    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

  13. #13
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    Yes, I saw that but the property is not included in the list if one wants to set it in code.

  14. #14
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    Try an image control on the form like I have and see if that fails as well.

  15. #15
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,943
    I now have it working with the picture property, so confused now as to why you cannot?
    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

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 6
    Last Post: 09-18-2020, 09:06 PM
  2. Replies: 5
    Last Post: 07-10-2020, 12:41 PM
  3. Replies: 3
    Last Post: 07-13-2015, 12:07 PM
  4. Printing form: image fails to update
    By stellar0645 in forum Forms
    Replies: 6
    Last Post: 02-04-2010, 11:41 AM
  5. Image control in MS Access
    By celestialcitizen in forum Forms
    Replies: 6
    Last Post: 07-03-2009, 03:25 PM

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