report to pdf: hidden mode seems to toggle

  • Thread starter Thread starter mary r
  • Start date Start date
M

mary r

In Access 2003, I have a report that I want to use with a Where Condition to
create a file. It doesn't much matter whether the destination format is rtf
with OutputTo or pdf using Steven Lebans' ConvertReportToPDF module; what
does matter is that the report is filtered using a coded Where condition and
that the report preview window NOT open.

I've tested this:
dtMyDate = Now()
stReportName = "MyReport"
stWhereCond = "MyReportSource.dtmMyDate = " & CStr(dtMyDate)
stFilePath = "MyDirectory\MyFileName.pdf"
....
DoCmd.OpenReport stReportName, acViewPreview, , stWhereCond, acHidden
blRet = ConvertReportToPDF(stReportName, , stFilePath, False, False)


The PDF creation works fine; what's driving me bonkers is that the acHidden
parameter seems to be toggling: every 2nd time I test, the report preview
window opens!

I've tried sending the report to rtf using OutputTo instead, but OutputTo
doesn't seem to accommodate filters or Where conditions.

Can anyone shed some light on this?

TIA-
mary
 
mary r said:
In Access 2003, I have a report that I want to use with a Where Condition to
create a file. It doesn't much matter whether the destination format is rtf
with OutputTo or pdf using Steven Lebans' ConvertReportToPDF module; what
does matter is that the report is filtered using a coded Where condition and
that the report preview window NOT open.

Either try closing the report after you've done the docmd.openreport
and the ConvertReportToPDF or try putting the filter in the VBA code
of the report instead which would elminate the docmd.openreport

For a page on how to print a report for a single record and how to
generate reports to attach to emails see the Emailing reports as
attachments from Microsoft Access page at
http://www.granite.ab.ca/access/email/reportsasattachments.htm

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
 
Back
Top