Outputting to PDF in A2007

  • Thread starter injanib via AccessMonster.com
  • Start date
I

injanib via AccessMonster.com

Hi, I am using Access 2007.
On the form I have a button that filtered report as follows.

Private Sub cmdPrint_Click()
Dim strWhere As String

strWhere = "[Invoice Number] = """ & Me.[txtInvoice] & """"

DoCmd.OpenReport "InvoiceReport", acViewReport, , strWhere

End Sub

Then I need to have this filtered report exported to pdf and save in a
specific location. I need this to happen simultaneously with report opening.
I have the following code for it.


Dim strPath As String

strPath = "C:\Invoice Database\Invoices\" & txtInvoice & ".pdf"
DoCmd.OutputTo acOutputReport, "InvoiceTable", acFormatPDF, strPath

txtInvoice is a field on my report.

I put the code on "Load" and "Open" event properties of the report. It fails
every time and gives me an error saying "This action can't be carried out
while processing a form or report event". There is a procedure running on the
reports footer format event, so I thought that is why. To test out whether my
code works at all I added it to the double click event of the report. When
the report opens and I double click, a small dialog boxes flashes really fast
saying "now outputting...." but it does not do any thing. It likes like it is
exporting the to pdf, but my destination folder is empty everytime I check.

can someone help and advise where should I place the code to have it initiate
the outputing process as the report is opening or after it is opened. How
would I change the code if I add it to the event procedure of my print button.


Why isn't the output actually happening when it appears like it is?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top