ACCESS 2013: Why is the DoCmd.OutputTo not rendering data correctly.

The OpenReport command renders data correctly in the OpenReport.  The PDF is missing the data.
----------------------------------------------------------------------------------------
    Dim strDirectory As String
    Dim strReport As String
    Dim strArgs As String

    strDirectory = "C:\School"
    strReport = "LunchReport" & ".pdf"
    strArgs = Forms![frmStudentCalendar]![cboMonth].Column(1)
    strArgs = strArgs & "|" & Forms![frmStudentCalendar]![cboMonth]
    strArgs = strArgs & "|" & Forms![frmStudentCalendar]![cboYear]

    DoCmd.OpenReport "rptEmailStudentCalendar", acViewReport, , , acWindowNormal, strArgs
   
    DoCmd.OutputTo acReport, "", acFormatPDF, strDirectory & "\" & strReport
    DoCmd.Close acReport, "rptEmailStudentCalendar", acSaveNo

I have also tried:
      DoCmd.OutputTo acReport, "", strFormat, strDirectory & "\" & strFileName & ".pdf"

Goal:  Create a pdf file to attached to an Email.
Sue TippettData Modeler, DBA, DAAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Anders Ebro (Microsoft MVP)Microsoft DeveloperCommented:
Not 100% sure, but have you tried to change
DoCmd.OpenReport "rptEmailStudentCalendar", acViewReport, , , acWindowNormal, strArgs
to
DoCmd.OpenReport "rptEmailStudentCalendar", acViewPreview, , , acWindowNormal, strArgs

Open in new window


and
DoCmd.OutputTo acReport, "", acFormatPDF, strDirectory & "\" & strReport
to
DoCmd.OutputTo acReport, "rptEmailStudentCalendar", acFormatPDF, strDirectory & "\" & strReport

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
To add a bit to Anders comment:

acViewReport opens the report in Report view. If you have VBA code in your report, much of that code will not run in Report view. It will run in Report view, so that may be the reason for the difference in your two view. Using acViewPreview shows the report in "Preview" mode, which typically will resolve this issue.
0
Jeffrey CoachmanMIS LiasonCommented:
So lets be clear:
The OpenReport command renders data correctly in the OpenReport.  The PDF is missing the data.
So you are saying that the report looks OK, ...but, the pdf is missing data?
Can you post a screenshot of the report (showing the correct Output) and the PDF (with the missing data)
It is not clear what "Missing data" means.

JeffCoachman
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Sue TippettData Modeler, DBA, DAAuthor Commented:
Yes, the report is executing code to populate check boxes.
ReportWithData.docx.doc
LunchReport.pdf
0
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
Then, as stated earlier, you should open the report in Preview mode, not Report mode, in order to make sure your code is firing. As Anders suggested:

DoCmd.OpenReport "rptEmailStudentCalendar", acViewPreview, , , acWindowNormal, strArgs
DoCmd.OutputTo acReport, "rptEmailStudentCalendar", acFormatPDF, strDirectory & "\" & strReport
DoCmd.Close acReport, "rptEmailStudentCalendar", acSaveNo
0
Sue TippettData Modeler, DBA, DAAuthor Commented:
I did exactly as suggested; same result

Code fires DoCmd.OpenReport "rptEmailStudentCalendar", acViewPreview, , , acWindowNormal, strArgs
not for DoCmd.OutputTo acReport, "rptEmailStudentCalendar", acFormatPDF, strDirectory & "\" & strReport

I will to think of a different approach to create the attachment.  Any suggests would be appreciated.
0
Sue TippettData Modeler, DBA, DAAuthor Commented:
Is  there a way to code this so the report does not display on the screen?  The application is looping through an email list which mean this is flashing   many times.  Thanks in advance.

                     DoCmd.OpenReport "rptLunchOrderForm", acViewPreview, , , acWindowNormal, strArgs
                        DoCmd.OutputTo acReport, "", acFormatPDF, strReportPath
                        DoCmd.Close acReport, "rptLunchOrderForm", acSaveNo
0
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
Change "acWindowNormal" to "acHidden" :

https://msdn.microsoft.com/en-us/library/office/ff195725.aspx
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.