Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Saving a PDF file

Posted on 2011-03-24
4
Medium Priority
?
292 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 2000 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 2000 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

Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

Question has a verified solution.

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

If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

926 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