Solved

Saving a PDF file

Posted on 2011-03-24
4
280 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

734 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