Check if Report is fully formatted

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • litpost
    New Member
    • Jun 2010
    • 9

    Check if Report is fully formatted

    We have Order DB in Access where we collect and send Order confirmation to Clients. In Order Form I click button to open Confirmation Report in Normal view. I have "Send Report" button on opened report to send it to Client in PDF format.

    All works grate with small reports. Problem arrise when report has 15-20 or more pages. After some investigation I found out that at time of report load user press Send button and report simply not being fully formated and sending action just fails.

    I cannot find correct event to check if report is finished formatting. It would help me to make Send button enabled true/false based on that status.
  • twinnyfo
    Recognized Expert Moderator Specialist
    • Nov 2011
    • 3662

    #2
    litpost,

    I'm not sure I understand either your question or your request. When a report is displayed in Access, it will format itself as you view consecutive pages.

    However, from what I understand, when you export a report to PDF, the entire report is generated using the Adobe drivers. Whether you use either of these two methods:

    Code:
    DoCmd.OutputTo acOutputReport, "ReportName", acFormatPDF, "FileName"
    
    or 
    
    DoCmd.SendObject , "ReportName", acFormatPDF, "EMailAddress"
    It has nothing to do with the display of the report.

    Are you able to determine exactly at what point the reports begin to cause problems? Is it at Page 8 or 9 or some other page number? Or is it only when reports have certain types of fields (or memo fields)? Sometimes, memo fields can cause headaches on reports.

    Comment

    • jforbes
      Recognized Expert Top Contributor
      • Aug 2014
      • 1107

      #3
      This might work for you. I haven't tried it:
      Code:
      If Not Application.CurrentProject.AllReports("YourReportName").IsLoaded Then
          DoCmd.OpenReport "YourReportName", acViewPreview, , "YourWhereClause"
      End If
      DoCmd.OutputTo acOutputReport, "YourReportName", acFormatPDF, "OutputDestination", True
      Another thing to consider is to put all the code to make the PDF into one button that way the Preview and the call to Output to PDF are on the same thread.

      Comment

      • jimatqsi
        Moderator Top Contributor
        • Oct 2006
        • 1293

        #4
        litpost,
        I've had lots of problems with emailing PDFs that took more time to be saved to disk than I allowed. I used the Bullzip PDF driver to create my PDFs because a lot of my work is in Access 2003. There are better options now but probably the same issue exists.

        I've had to build in pauses, sometimes long pauses, or a loop that keeps looking for the file to exist before trying to send the email with the PDF attached. When I'm creating multiple reports to send, I've found it's best to create all the reports first and then send all the emails.

        My experience may or may not apply to your case. What does your code look like?

        Jim

        Comment

        • litpost
          New Member
          • Jun 2010
          • 9

          #5
          We have "Send" button on Confirmation Report. Report loads in acNormal view and sometimes it takes couple of seconds. To send report I use
          Code:
          docmd.sendObject
          If some non-patient user hits "Send" button before Report finishes to load it brings them error. I need to freeze "Send" button until report is fully loaded/formatted.

          Jim, I had similar idea first to save PDF file on disk and after send it. But I doubt it solves my issue because anyway Output must be finished before sending. How shall I control this? Using Timer is not very good way as some reports load immediately and for others it takes 5-15 or even more seconds.

          Comment

          • zmbd
            Recognized Expert Moderator Expert
            • Mar 2012
            • 5501

            #6
            in your code have you set a Trap for error?

            Comment

            • litpost
              New Member
              • Jun 2010
              • 9

              #7
              Yes, I have. I can trap error and maybe someway retry sendObject row. Its one of solutions, however, not the best.

              Another solution maybe with timer help.
              Here I have question: when exactly Report ontimer event starts?

              Comment

              • litpost
                New Member
                • Jun 2010
                • 9

                #8
                I solved it at last.

                - switched on docmd.Hourglass before button which opens the Report (button is located on Order Form) and switched off docmd.Hourglass on exit sub.

                - in OnClick event of "Send" button at the top did the check for MousePointer

                Code:
                If Screen.MousePointer = 11 Then Exit Sub
                Now User is not able to start sending until all process of button on Order Form is finished. That is actualy strange but somehow it solved the issue. Thank you all for help!

                Comment

                Working...