Solved

Saving a PDF file

Posted on 2011-03-24
4
245 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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

759 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now