Results 1 to 7 of 7
  1. #1
    Tlo is offline Advanced Beginner
    Windows 8 Access 2016
    Join Date
    Jan 2016
    Posts
    41

    Image Field via Image Path Not Displaying on Exported Report in PDF Format

    Hello All,

    I've got a report that has two sub forms on it that are continuous forms. Each of the forms have image controls that are set up to show the following, which is set as the control source of the field: =Replace([ENHServiceImagePath1],Chr(34),""). The field "ENHServiceImagePath" is a path name to a stored file on our network. Here is the actual field in it's raw form before going through the replace function: "Z:\Images and Attachments\Services\Bolton Park_EST_1493_SERV1_1945_th.jpg"

    The report is a proposal, and the images need to display on the report when exported to PDF format. When you open the report, the images are there, however, when you export the report SOMETIMES the images aren't there. Sometimes only say 2 of 4 images are there, sometimes 1 of 4, sometimes none. I've really been racking my brain trying to figure this out. I thought I solved the issue a couple of weeks ago by incredibly painful trial and error, by setting the focus to the sub forms immediately prior to exporting to PDF. That seemed to work, but today a user sent me the issue that it happened again. I'm probably missing something simple, but I can't seem to make any logic of when it does or doesn't display, and I can't replicate the problem intentionally. The sub forms are linked to the main form via ENHServiceID and ENHServiceID_FK. I don't think that's the issue since the images are visible on the report.

    Any help is greatly appreciated. I've spent hours and hours and hours trying to figure this out.

    Below is the code in the On Load event of the sub form.

    If IsNull(ENHServiceImagePath1) Then
    Me.imgServAttmt1.Height = 0
    Me.Detail.Height = 0
    Else
    Me.imgServAttmt1.Height = 5750
    Me.Detail.Height = 5750
    End If
    '''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''
    Below is my code that is behind an "Export To PDF" button on the report.
    '''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''
    Private Sub cmdExportPDF_Click()

    On Error GoTo cmdErrHandler

    Dim intEstNum As Integer

    intEstNum = Me.EstimateID

    DoCmd.Close acForm, "ENHfrmProposal", acSaveYes
    DoCmd.Close acForm, "ENHfrmChooseProposalNEW", acSaveYes



    Me.ENHfrmProposal_Images_Attmt1.SetFocus
    Me.ENHfrmProposal_Images_Attmt2.SetFocus

    DoCmd.OutputTo acOutputReport, "ENHrptEnhanceProposal_WithOutServicePricing", acPDF, , True, , , acExportQualityPrint
    DoCmd.Close acReport, "ENHrptEnhanceProposal_WithOutServicePricing", acSaveYes

    DoCmd.OpenForm "ENHfrmProposal", , , "[EstimateID] = " & intEstNum, , acWindowNormal

    cmdErrHandler:
    Select Case Err.Number
    Case 3048
    MsgBox "Unexpected Error, Please Close the Databse and Reopen", vbCritical, "Error"
    Case 2501
    MsgBox "The Existing PDF File Is Currently Open, Please Close and Try Again", vbCritical, "Error"
    Case 0
    Exit Sub
    Case Else
    MsgBox Err.Number & ": " & Err.Description & ": cmdExportPDF_Click"
    End Select

    End Sub

  2. #2
    Tlo is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jan 2016
    Posts
    41
    I see that there have been 50 views on this post but no one has commented on it. Am I doing something wrong? The last time I posted in this forum (about a year ago) I got no responses either. I'm not used to the forum so if I'm missing something please let me know.

  3. #3
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,825
    Might post code with code tags to retain indentation and improve readability. This will encourage readers to give more attention. Edit your post.

    I will look at later.

    I see you have a number of threads that have received replies. Looks like pretty good track record to me.
    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.

  4. #4
    Tlo is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jan 2016
    Posts
    41

    Arrow

    Thanks June7 for the reply. I've found this forum to be incredibly useful in the past, I just wanted to be sure I wasn't doing something wrong. Not a complaint at all, I'm very grateful for any help that I can get. Also, I just figured out how to wrap the code, my apologies for the readability problem.

    Below is code for the on load event for the sub forms that contain the images.
    Code:
    If IsNull(ENHServiceImagePath1) Then
            Me.imgServAttmt1.Height = 0
            Me.Detail.Height = 0
       Else
            Me.imgServAttmt1.Height = 5750
            Me.Detail.Height = 5750
    End If
    Below is code behind "Export To PDF" button.
    Code:
    Private Sub cmdExportPDF_Click()
    
    
    On Error GoTo cmdErrHandler
    
    
    Dim intEstNum As Integer
    
    
    intEstNum = Me.EstimateID
    
    
    DoCmd.Close acForm, "ENHfrmProposal", acSaveYes                 'close forms that are open to speed up export process
    DoCmd.Close acForm, "ENHfrmChooseProposalNEW", acSaveYes        'close forms that are open to speed up export process
    
    
    Me.ENHfrmProposal_Images_Attmt1.SetFocus                        'set focus to sub form image 1
    Me.ENHfrmProposal_Images_Attmt2.SetFocus                        'set focus to sub form image 2
    
    
    DoCmd.OutputTo acOutputReport, "ENHrptEnhanceProposal_WithOutServicePricing", acPDF, , True, , , acExportQualityPrint
    DoCmd.Close acReport, "ENHrptEnhanceProposal_WithOutServicePricing", acSaveYes
    
    
    DoCmd.OpenForm "ENHfrmProposal", , , "[EstimateID] = " & intEstNum, , acWindowNormal            're-open form where user was working before the export process
    
    
    cmdErrHandler:
        Select Case Err.Number
            Case 3048
               MsgBox "Unexpected Error, Please Close the Databse and Reopen", vbCritical, "Error"          'this was for "Cannot Open Any More Databases", I've since simplified source for report to eliminate this
            Case 2501
                MsgBox "The Existing PDF File Is Currently Open, Please Close and Try Again", vbCritical, "Error"
            Case 0
                Exit Sub
            Case Else
                MsgBox Err.Number & ": " & Err.Description & ": cmdExportPDF_Click"
        End Select
    
    
    End Sub

  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,825
    Sorry, I don't know how I can help with an intermittent issue. Not something I've ever experienced. I just tested exporting a 103 page report (no subreport) and all 206 images rendered. I used the right click shortcut menu on the report and tested both Standard and Minimum Size options.

    I did a quick Bing search on the topic and you are not the only one to encounter this. https://social.msdn.microsoft.com/Fo...orum=accessdev
    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
    Tlo is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jan 2016
    Posts
    41
    Thanks June7. That's what is so frustrating to me, is that I can't intentionally replicate the problem therefore I can't fix it. Question - are your images displayed using a file path name, or are they attachment fields in the database? My images are displayed using a path name.

    I tried having attachment solely for the purpose of ease of use, but the DB bloated from 20 MB to 1.5 GB in a few weeks, so I had to fix. Side note: my user community includes people that are very computer illiterate, so making the application user friendly is the highest priority. It turns out that copying file path names and pasting them into fields is too much for my group. What I've figured out how to do is the following: add field data type attachment to new table. On the form where user interacts to add images, the user can use the nice and neat user interface that comes with attachment field in Access. In the AfterUpdate event I save the record, open a recordset, export the actual file to a consistent location on the server, create an image path, display the image using the image path, and then delete the attachment. This way I get the best of both worlds - easy user interface and no DB bloat. If this could help anyone let me know and I'll post code.

    The best explanation I can come up with I can come up with for my original problem is the size of the images in this particular report. I say this because Other reports with many more images work fine. Each file in question here is 20 MB.

    Thanks again for replying June7. I'll mark this thread in a couple days. Is there a way I can give you credit/points?

  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,825
    External images. However, the db and images are on a laptop, no server.

    I was wondering about image size, meant to ask. My largest image is 1.2MB You may have to use an imaging app to resize. MSPaint can do it.

    If you want an interface for users to browse and select a file name for storing in text field, try Windows FileDialog code.

    You can click the star-like icon to award rep.
    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: 2
    Last Post: 03-14-2018, 11:10 AM
  2. Replies: 6
    Last Post: 09-02-2016, 12:52 PM
  3. Replies: 10
    Last Post: 01-09-2014, 03:00 AM
  4. Replies: 1
    Last Post: 05-14-2013, 11:49 AM
  5. Displaying image in calculated field
    By ceci123 in forum Access
    Replies: 2
    Last Post: 01-25-2011, 11:51 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