Solved

Access PDF orientation issues after upgrade from 2007 to 2010

Posted on 2011-02-17
5
1,465 Views
Last Modified: 2012-05-11
After upgrading to Access 2010 when my module converts to PDF it puts all reports in landscape rather than portrait. I have checked all the settings in Access and everything shows to be in the proper portrait settings. I am using a 3rd party module to do this conversion. Looking around online it looks like Access now has a built in PDF converter. If this is the case, can someone please help me with the new piece of code.
Option Compare Database
Function send_emailcap_mtd()
   On Error GoTo Err_Send_Click

    Dim mydb As Database, RS As Recordset
    Set mydb = DBEngine.Workspaces(0).Databases(0)

    Dim docname As String, ctl As Control, strTo As String
    Dim path As String, subject As String, body As String
    Dim attach As String, blnSuccessful As Boolean
        

    Application.Echo False
    'Get all the email addresses  for the daily stat report
    Set RS = mydb.OpenRecordset("qry_emailcap_mtd")
       
    'Report to run and make a snapshot of the report and put it on the server
    path = "c:\temp\"
    docname = "emailcap_mtd"
    subject = "Email Address Capture Report"
    body = "Daily Report is Attached"
    attach = path + docname + ".rtf"
    'DoCmd.OpenReport docname, A_PREVIEW
    DoCmd.OutputTo acOutputReport, docname, acFormatRTF, _
    attach, False
    
'start of pdf change
    Dim blRet As Boolean
    Dim attachPDF As String
    attachPDF = path + docname & ".pdf"
    ' Call our convert function
    ' Please note the last param signals whether to perform
    ' font embedding or not. I have turned font embedding ON for this example.
      blRet = ConvertReportToPDF(docname, vbNullString, _
      attachPDF, False, True, 150, "", "", 0, 0, 0)
    ' To modify the above call to force the File Save Dialog to select the name and path
    ' for the saved PDF file simply change the ShowSaveFileDialog param to TRUE.
'end of pdf change
    
    'This loops through all of the email addresses and sends the report to everyone
    Do Until RS.EOF
      strTo = RS!Email
       'Old format for sending reports with warnings
       'DoCmd.SendObject A_REPORT, docname, A_FORMATTXT, strTo, , , "Daily Stat Report", , False
       'New way of sending reports without warnings

'       blnSuccessful = FnSafeSendEmail(strTo, subject, body, attach, "", "")
       blnSuccessful = FnSafeSendEmail(strTo, subject, body, attachPDF, "", "")
       RS.MoveNext
    Loop
    'Clean up process
    RS.Close
    DoCmd.Close A_REPORT, docname
    Set RS = Nothing
    Set mydb = Nothing

exit_send_click:
    
    Application.Echo True
    Exit Function

Err_Send_Click:
    Resume exit_send_click
    
End Function

Open in new window

0
Comment
Question by:Cole100
  • 2
  • 2
5 Comments
 
LVL 7

Expert Comment

by:shaydie
ID: 34921196
To output to a PDF using built-in functionality
Output your report to strPath and attach to email...

strPath = "c:\mypath\DailyRpt-" & fDate & ".pdf"
DoCmd.OutputTo acOutputReport, "Report", acFormatPDF, strPath

0
 
LVL 10

Expert Comment

by:LukeChung-FMS
ID: 34923402
The syntax for the constants "A_" come from Access 2.0 days.

0
 

Author Comment

by:Cole100
ID: 34930354
Can you help me out with where to place this piece of code. I am having no luck on getting this to works. Thanks
0
 
LVL 10

Expert Comment

by:LukeChung-FMS
ID: 34930449
I haven't seen situations where the report is in one mode and the PDF comes out in another. Are you experiencing this problem when you generate the PDF interactively from previewing the report?
0
 
LVL 7

Accepted Solution

by:
shaydie earned 250 total points
ID: 34930592
Hi Cole,

I'm guessing that something like this should work.. edited code below:

Function send_emailcap_mtd()
   On Error GoTo Err_Send_Click
 
    Dim mydb As Database, RS As Recordset
    Set mydb = DBEngine.Workspaces(0).Databases(0)
    Dim attachPDF As String
    Dim docname As String, ctl As Control, strTo As String
    Dim path As String, subject As String, body As String
    Dim attach As String, blnSuccessful As Boolean
         
     Application.Echo False
    'Get all the email addresses  for the daily stat report
    Set RS = mydb.OpenRecordset("qry_emailcap_mtd")
       
    path = "c:\temp\"
    docname = "emailcap_mtd"
    attachPDF = path + docname & ".pdf"
    subject = "Email Address Capture Report"
    body = "Daily Report is Attached"
    DoCmd.OutputTo acOutputReport, docname, acFormatPDF, attachPDF
     
    'This loops through all of the email addresses and sends the report to everyone
    Do Until RS.EOF
      strTo = RS!Email
       'Old format for sending reports with warnings
       'DoCmd.SendObject A_REPORT, docname, A_FORMATTXT, strTo, , , "Daily Stat Report", , False
       'New way of sending reports without warnings
 
'       blnSuccessful = FnSafeSendEmail(strTo, subject, body, attach, "", "")
       blnSuccessful = FnSafeSendEmail(strTo, subject, body, attachPDF, "", "")
       RS.MoveNext
    Loop
    'Clean up process
    RS.Close
    Set RS = Nothing
    Set mydb = Nothing
 
exit_send_click:
     
    Application.Echo True
    Exit Function
 
Err_Send_Click:
    Resume exit_send_click
     
End Function
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
Familiarize people with the process of utilizing SQL Server views 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 Access…
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…

758 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

23 Experts available now in Live!

Get 1:1 Help Now