Solved

Saving a PDF file

Posted on 2011-03-24
4
264 Views
Last Modified: 2012-06-21
I have 2 bits of code whose logic I wish to combine;
The bottom line is that I want to write a PDF to my C: Drive.

Code A below generates a report correctly.  Note the sWhere filter.
Code B writes to disk but DOES not have a filter.

I guess I want to know - How do I write code B with the filter.

(Hopefully this is clear, it is late here and time for bed!)
CODE A
=======
sWhere = "[CustomerID] = " & Me.CustomerID
DoCmd.OpenReport "rptOrderDetails", acViewPreview, , sWhere

Code B
=======
DoCmd.OutputTo acReport, "rptorderdetails", acFormatPDF, "myreport" & ".pdf", False, ""

Open in new window

0
Comment
Question by:Patrick O'Dea
  • 2
  • 2
4 Comments
 
LVL 4

Accepted Solution

by:
tabish earned 500 total points
ID: 35212217
Is the RecordSource of you report a table or a query? If it is a table change it to a saved query and then modify the query before exporting it to PDF:

You can do the something like that

Dim db As DAO.Database
Dim qdExtData As QueryDef
       
    Set db = CurrentDb
   
    Set qdExtData = db.QueryDefs("SavedQueryName")
       
     qdExtData.SQL = qdExtData.SQL & "Where CustomerID =  " & Me.CustomerID
     
    qdExtData.Close
    db.Close
    Set db = Nothing

DoCmd.OutputTo acReport, "rptorderdetails", acFormatPDF, "myreport" & ".pdf", False, "" 

This code may have bugs in it but it will give you an idea what you can do.


0
 

Author Comment

by:Patrick O'Dea
ID: 35213009
Thanks,
I should have clarified in the first instance.
It is not really a report at at (!)  It is a single page output of ONE record.

Hence the output is more like a screen dump of customer data.
I do not need a recordset.
I just want the single record output where the customerID joins the report and the form.
0
 
LVL 4

Assisted Solution

by:tabish
tabish earned 500 total points
ID: 35213057
the code above should produce the same result as your CODE A but in the form of PDF.
Probably you are confusing "RecordSource" with recordset.

0
 

Author Closing Comment

by:Patrick O'Dea
ID: 35226125
Thanks I have nearly got it...
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question