Results 1 to 11 of 11
  1. #1
    MaestroC is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2014
    Posts
    6

    Displaying image from disk when path is stored as calculated field

    I am very much a noob here so please talk slowly for me.

    I have a database named Students. In it is a field named StudentID and another named StudentPhoto. StudentPhoto is a calculated field that pulls in the StudentID and inserts it into a local URL like this- "C:\Users\...\...\SCHOOL\Pictures\students28540.jp g" Specifically the calculated field has this expression in it:

    "C:\Users\...\...\SCHOOL\Pictures\students" & [studentstudentNumber] & ".jpg"

    I have all of the student photos in that same folder and the lookup field is working correctly, showing me the correct path to each image file.

    My question is how the heck do I get their images to display in a report I have created? I have made a bound image on the report and attempted to connect it to the Students.StudentPhoto field but all it does is display an empty box.

    I've tried a few scripted methods for doing this that I found on searches but I can't seem to get it to work. The one that came closest I thought was this one: http://www.databasedev.co.uk/bound_image_report.html but the script always gave an error that it couldn't find the table field.

    Anyone have an easy, direct way to do this?

    Sincerely,


    MaestroC

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Did you use an Image control and set its ControlSource property to the path field?
    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
    MaestroC is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2014
    Posts
    6
    Yes, I think...

    I clicked the image icon. Dragged a box. A window popped up asking for the image to attach to it. I picked one at random just to get rid of the box. Then I went in and put the StudentImage field in the ControlSource box. The same image stays on the screen for every record (the image that I chose when placing the image box).

    If I drag the box and cancel out of selecting an image then selecting the field as before nothing shows up on the rendered report.

    The data source for the report is a query that pulls data from several tables (if that matters at all).

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Check out this post and then post #6 to double check where you are at.
    https://www.accessforums.net/databas...tml#post192105

  5. #5
    MaestroC is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2014
    Posts
    6
    Quote Originally Posted by ItsMe View Post
    Check out this post and then post #6 to double check where you are at.
    https://www.accessforums.net/databas...tml#post192105
    I went to that thread and followed the instructions in post #10 of that thread:
    I use an image control to dynamically display images on a form. When I first create the control, I have the wizard turned on. I select a temp image that is sized approx. to the size I will be using in my form.

    After I create the image control I give the control the name I want and save the form.

    Then I clear the Picture property for the Image Control. Access will ask you if you want to delete the image. Answer yes and save the form.

    Now you can dynamically update the Picture property of the Image Control. Use your image path as June7 explained in post # 6
    The only thing that I am possibly doing different is that I clicked the image icon in the toolbar to insert the image placeholder into the report. Not sure if this is having the "wizard turned on" that is mentioned in the quote.

    I go through the other steps and this is the value I am pasting into the Control Source box in the image properties:

    ="C:\Users\...\Dropbox\SCHOOL\Pictures\students " & [studentstudentNumber] & ".jpg"

    I know that path is correct because if I paste it into the Control Source of a plain text box it shows the full path and that path changes correctly for each record. It shows in the report like this:

    C:\Users\...\Dropbox\SCHOOL\Pictures\students28540 .jpg

    Pasting the exact same path calculation into the Control Source of the image however does not work. If I put the same calculated image path into the Control Source box of the images properties when I switch to report view I get an empty white box where the image should be at.

  6. #6
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Nothing is jumping out saying it should not work. I am not familiar with calculated fields in tables...

    Maybe try moving to VBA. It may be easier to troubleshoot. In your form's current event you could place

    Me.ImageControlName.ControlSource = "C:\Users\...\Dropbox\SCHOOL\Pictures\students " & Me![studentstudentNumber] & ".jpg"

    This is assuming studentstudentNumber is the name of a control bound to your calculated field in your table. You will need to adjust he code to include the name of your Image Control

  7. #7
    MaestroC is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2014
    Posts
    6
    Quote Originally Posted by ItsMe View Post
    Nothing is jumping out saying it should not work. I am not familiar with calculated fields in tables...

    Maybe try moving to VBA. It may be easier to troubleshoot. In your form's current event you could place

    Me.ImageControlName.ControlSource = "C:\Users\...\Dropbox\SCHOOL\Pictures\students " & Me![studentstudentNumber] & ".jpg"

    This is assuming studentstudentNumber is the name of a control bound to your calculated field in your table. You will need to adjust he code to include the name of your Image Control
    The [studentstudentNumber] is not a control name, it is the name of a field in the 'student' table. Also, not sure if this matters, but this whole thing is being done in a report rather than a form.

    I will try the VBA thing you mentioned and report back.

    Thank you!

  8. #8
    MaestroC is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2014
    Posts
    6
    The following text is now in the editor for the OnCurrent line in the report properties:

    Private Sub Report_Current()
    Me.StuPic.ControlSource = "C:\Users\Chad.Criswell\Dropbox\SCHOOL\Pictures\st udents " & Me![studentstudentNumber] & ".jpg"
    End Sub



    Same thing still happens. Blank white box instead of the individual student's image.

  9. #9
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    I know dynamic image control can work, done it.

    Want to provide db for analysis? Follow instructions at bottom of my post.
    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
    MaestroC is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2014
    Posts
    6
    Quote Originally Posted by June7 View Post
    I know dynamic image control can work, done it.

    Want to provide db for analysis? Follow instructions at bottom of my post.
    Here's the cleaned out database. Please don't laugh too hard at it.

    FYI, the report I am speaking of is titled Achievements Chart. It is eventually going to be used to print little wall charts for each student to show their progress on playing their scales in my beginning band classes. I am sure the whole table and field structure could be more efficient but this was always intended to be for my use only and was never going to scale up to something professional.

    Please feel free to take a look and let me know what you think.

    Database11safe.zip

  11. #11
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    I deleted the image control and the code to set its ControlSource. Created a new image control. When the Insert Picture file picker opened I clicked Cancel. I typed the expression in the ControlSource. Opened report in Print Preview, Report View, and Layout View - all worked. The image changes for each record.
    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: 1
    Last Post: 05-14-2013, 11:49 AM
  2. Replies: 8
    Last Post: 11-10-2012, 03:03 AM
  3. Displaying image in calculated field
    By ceci123 in forum Access
    Replies: 2
    Last Post: 01-25-2011, 11:51 AM
  4. Pass image parameter to stored procedure
    By Kencao in forum Programming
    Replies: 3
    Last Post: 04-28-2010, 11:51 PM
  5. Replies: 6
    Last Post: 04-18-2010, 03:41 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