Results 1 to 7 of 7
  1. #1
    apagan1959 is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2019
    Posts
    3

    Load images dynamically in Report

    I have an Image Control in a report. The "Picture Type" is set to "Linked" and I've left the "Source Control" blank. I want to be able to set what image is displayed in the Image Control using VBA. I've made several attempts using the following:

    Image.Property = "c:\images\image_name.jpg"

    But, I am quite sure that is not the correct syntax or function. I've done some Googling, but have not found a solution. Would someone point me in the write direction, please.

    Thanks, in advance.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Is Image the name of the Image control? What event is the code in? Review http://www.databasedev.co.uk/bound_image_report.html

    Why don't you use ControlSource property and not VBA? The VBA method will not work in ReportView, only PrintPreview or direct to printer.
    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.

  3. #3
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,407
    This report works for me. The control on the report is an Image object. In my case the path is in the recordsource for the report.
    Click image for larger version. 

Name:	image.png 
Views:	18 
Size:	25.7 KB 
ID:	37562

    Format properties:
    Click image for larger version. 

Name:	Image2.png 
Views:	18 
Size:	16.8 KB 
ID:	37563
    Last edited by davegri; 02-23-2019 at 11:03 PM. Reason: path comment.

  4. #4
    apagan1959 is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2019
    Posts
    3
    No the acctual control name is "HoFImage". The reason I want to use VBA is because the image is only displayed for rows that meet the WHERE criteria. Therefore, I have an IF statement in my VBA that looks to see if the WHERE criteria has been met, if so, the image is displayed (if not, the image is not displayed). So, what I am trying to do is get the appropriate VBA code to assigned the image to the Control only when the image is to be presented.

    Thanks.

  5. #5
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,407
    June7 requested information, and I'll try likewise:
    What's the RecordSource for the report? Is the image path in the RecordSource? Where is the VBA "WHERE" criteria? What VBA code have you tried, and what event is it in?
    One technique that I have used is if there is no image file, display an image that has the text "No Image Available", in which case an image is always available.

  6. #6
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,114
    Image.Property = "c:\images\image_name.jpg"
    You use the .Picture property not the "property" property, so it would be HoFImage.Picture="c:\images\image_name.jpg"

    Cheers,
    Vlad

  7. #7
    apagan1959 is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2019
    Posts
    3
    Thanks to all the responses that I've recieved, I've figured it out! I am now able to display an image on a report based on the value of a query (now, an if statement). Here is what I am doing. I am using an IMAGE control and Control Source I am using an If Statement that compares a TempVar, which gets its value from a field in a table.

    Here is the actual statement I am using in the Control Source
    =IIf([TempVars]![HoF]="Y","C:\image\HoF.jpg")

    I set the HoF TempVars when the user clicks on submit (using VBA). I do a DLookup that sets its value.

    TempVars!HoF = DLookup("[column]", "[Table]", "[table].[column]=Y")

    Sounds convoluted, but it is working. Thanks all!

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

Similar Threads

  1. Replies: 2
    Last Post: 02-05-2018, 01:21 PM
  2. Replies: 2
    Last Post: 03-31-2015, 03:32 AM
  3. Replies: 7
    Last Post: 03-27-2012, 09:51 AM
  4. Load images in access using iif function?
    By sureshfina in forum Forms
    Replies: 1
    Last Post: 12-22-2009, 11:05 AM
  5. Replies: 17
    Last Post: 08-26-2009, 11:27 AM

Tags for this Thread

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