Results 1 to 3 of 3
  1. #1
    enzokevin is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Apr 2013
    Posts
    13

    Path to linked images breaks when I close database

    Help needed:


    I have a report in Access 2010. The report contains some images in the main report area and in sub reports. I have The queries that feed the report and subreport contains the name of the pictures that are loaded into its image controls. I added the following code to my form in order to control what image is displayed for each record. Id like the form to work even if the database is moved as long as the subfolder and photos are moved along with it (thus using relative path).

    Code:
    Private Sub Report_(Current)
        Dim ImagePath As String
        Dim ImagePathInt As String
        Dim ImagePathPlanV As String
        
        ImagePath = GetImagePath & Me!BackPhName
        ImagePathInt = GetImagePath & Me!IntPhName
        ImagePathPlanV = GetImagePath & Me!PlanVSketch
        
        If Len([BackPhName]) > 0 And Len(Dir(ImagePath)) > 0 Then
        ImgBackground.Picture = ImagePath
        Else
        ImgBackground.Picture = ""
        End If
        
        If Len([IntPhName]) > 0 And Len(Dir(ImagePathInt)) > 0 Then
        ImgInternal.Picture = ImagePathInt
        Else
        ImgInternal.Picture = ""
        End If
        
        If Len([PlanVSketch]) > 0 And Len(Dir(ImagePathPlanV)) > 0 Then
        ImgInternal.Picture = ImagePathPlanV
        Else
        ImgInternal.Picture = ""
        End If
    End Sub
    Public Function GetImagePath() As String
        GetImagePath = GetDBPath & "Renamed Photos Videos and Sketches\"
    End Function
    Public Function GetDBPath() As String
    GetDBPath = CurrentProject.Path & "\"
    End Function
    The problem seems to be that the routine doesn't seem to initially recognize the path. I have a blank photo in the folder containing all the images called NO PHOTO.jpg. If I open the report in design view and browse to this image in the picture parameter of any one of the image controls and run the report, then everything works perfectly even if I close and reopen the report. The report shows the right pictures even in the subreports. The problem is when I close the database and reopen it, then the link is lost again, forcing me to do the process of browsing for the NO PHOTO image again.
    I already try to do an open form procedure to automatically reset the picture property, but although it resets the picture to the picture I set (I verify this by setting a different picture instead of the NO PHOTO) it does not make things work correctly as it does when I manually browse for it in design view.
    I also try to run the code above under the Report (Open) instead of the Report (Current) but that didn't work either. Any help figuring this out is greatly appreciated.
    Thanks.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    I use an Image Control and set its ControlSource property.
    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
    enzokevin is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Apr 2013
    Posts
    13
    Yes, I did figure that out. A simple solution and took me hours to figure it out. For the other novices like me here is the solution:
    Instead of trying to retrieve the path with the code above I retrieve it at the Image Control Source property as June7 suggested.
    In design view, click the properties of the image control.
    =[CurrentProject].[path] & "\Renamed Photos Videos and Sketches" & "\" & [RecordContainingthephotofilename]
    In this case I had to do this with every image control in every report and subreport.

    thanks for your reply June7

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

Similar Threads

  1. Linked .emf images will not center align.
    By sonoamore in forum Access
    Replies: 5
    Last Post: 11-13-2014, 07:01 PM
  2. Replies: 6
    Last Post: 01-28-2014, 06:40 AM
  3. Print Linked Images in a Report
    By bosve73 in forum Reports
    Replies: 4
    Last Post: 02-02-2012, 11:12 AM
  4. Display Linked table Path
    By gg80 in forum Access
    Replies: 3
    Last Post: 10-14-2011, 10:02 PM
  5. Replies: 1
    Last Post: 03-18-2011, 04:07 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