Results 1 to 15 of 15
  1. #1
    Middlemarch is offline Competent Performer
    Windows 10 Access 2019
    Join Date
    Mar 2015
    Posts
    374

    Changing image source

    My image control is bound to a query, but I'd like to conditionally change the picture but restore it when moving to another record.
    I tried using a second image control and toggling visible as required but it didn't quite work out.
    Can I have one image control and change it source between the query and an alternate picture file?
    VBA seems to error when changing the control source, but I may be doing it incorrectly.

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows 10 Office 365
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,746
    Did you look at Similar Threads at the bottom of the page to see if any offered insight on an approach?
    There is one marked SOLVED that has 7 posts.... worth a look.

    It would be helpful if you posted some of your code and showed the problem area and what you'd like to achieve.
    Last edited by orange; 05-12-2024 at 05:14 AM. Reason: spelling

  3. #3
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2013 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,125
    Usually it is done by setting the Picture property of the image control in the Current event of the form; basically you would use Len(Dir(yourPath))=0 to check if the file supplied by the query exists (or maybe the query returns Null if no file available) and you set the Picture property to your alternate picture.

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  4. #4
    Middlemarch is offline Competent Performer
    Windows 10 Access 2019
    Join Date
    Mar 2015
    Posts
    374
    Thank you. Have now changed to using a Form with Border style none (instead of an image control)
    and the problem has gone away.

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,972
    All images are external from database? What condition for display of image files? Can have IIf() expression in ControlSource. I have never used Picture property for dynamic display of images.
    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.

  6. #6
    Middlemarch is offline Competent Performer
    Windows 10 Access 2019
    Join Date
    Mar 2015
    Posts
    374
    Yes the images are external. You gave me the instructions for using a query so the screen would not flicker as images changed.
    I haven't changed that, this is a addition. It's all working as hoped except I cannot detect a click event in the picture.
    The Form click event doesn't work and there's no Picture click event. So not sure how to resolve that.

  7. #7
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,972
    Image control has Click event. Why do you need it? You said you wanted image displayed according to a condition. What is that condition?

    IIf() expression can be in query and Image control reference that calculated field or expression in ControlSource.
    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.

  8. #8
    Middlemarch is offline Competent Performer
    Windows 10 Access 2019
    Join Date
    Mar 2015
    Posts
    374
    I'm now using a Form to display a thumbnail size picture. It represents the current item in a datasheet.
    I want that to open a larger resizable form showing the same picture.
    But the Click event fails. Is there any way to make it work?

  9. #9
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,972
    Image control Click event works for me.

    What do you mean by "fails" - error message, wrong result, nothing happens? Want to show code or provide files?

    Pictures don't show on form in Datasheet view therefore can't click on Image control.

    Not clear to me what you are doing.
    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.

  10. #10
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,458
    initial requirement

    I'd like to conditionally change the picture but restore it when moving to another record.
    plus

    I'm now using a Form to display a thumbnail size picture. It represents the current item in a datasheet.
    I want that to open a larger resizable form showing the same picture.
    equals confusion

  11. #11
    Middlemarch is offline Competent Performer
    Windows 10 Access 2019
    Join Date
    Mar 2015
    Posts
    374
    How come? Pretty straightforward I'd have thought. Maybe your first language isn't English ?
    Read it again and think about what I've said.

  12. #12
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,972
    Quote Originally Posted by Middlemarch View Post
    Can I have one image control and change it source between the query and an alternate picture file?
    Direct answer is "yes". ControlSource of Image control can be an IIf() expression that determines whether to use field data for file location or static string for alternate image filename.

    Then you state:
    Quote Originally Posted by Middlemarch View Post
    I'm now using a Form to display a thumbnail size picture. It represents the current item in a datasheet.
    I want that to open a larger resizable form showing the same picture.
    But the Click event fails. Is there any way to make it work?
    Click event where - the thumbnail and this is an Image control? Again, show code or provide database.

    As I said, Click event for Image control works for me. I have no idea what you have attempted.
    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.

  13. #13
    Middlemarch is offline Competent Performer
    Windows 10 Access 2019
    Join Date
    Mar 2015
    Posts
    374
    I changed the picture from an Image control to a Form using the Forms picture property.
    But that Forms click event isn't working, whether the picture is present or not.
    Should it? It's popup, not modal, not datasheet. and not using headers or footers.

  14. #14
    CarlettoFed is offline Competent Performer
    Windows 7 64bit Access 2013 32bit
    Join Date
    Dec 2019
    Posts
    261
    Attach a sample file and everything will be faster.

  15. #15
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,972
    I tested. The event triggers only when I click on record selector at left side of form. If record selector is inactive, no click trigger.
    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.

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. Changing Image with each click of Image.
    By mainerain in forum Access
    Replies: 7
    Last Post: 01-19-2020, 07:05 PM
  4. Image Control with Filepath as Source
    By tennislvr7 in forum Forms
    Replies: 1
    Last Post: 01-22-2014, 10:59 PM
  5. Changing report image
    By mmlinar in forum Reports
    Replies: 1
    Last Post: 09-17-2012, 01:57 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