locked
An Access problem-setting landscap view for pof RRS feed

  • Question

  • Hi,

    I have a dashboard form, in which there is a pdf icon,whenever user click on that pdf icon the access report is get converted into pdf documents.

    Now the problem is that when i open that pdf document it open into potraite view and the graph of the report spilt into two page.

    what i want that the pdf file is open into landscap view ,so that graph able to into view into one page.

    what i do,plz help.

    Friday, May 27, 2011 3:51 PM

Answers

  • This is the code that i have  written for the click event of pdfIcon

    Private Sub cmdPrintReportPDF_Click()

     

    If Form_Graphs.tab_graph.Value = 2 Then

      DoCmd.OpenReport "Graph_Report_FieldShifts", acViewNormal
        DoCmd.OutputTo acOutputReport, "Graph_Report_FieldShifts"
        DoCmd.Close acReport, "Graph_Report_FieldShifts"

     Else
        DoCmd.OpenReport "Graph_report", acViewNormal
        DoCmd.OutputTo acOutputReport, "Graph_report"
        DoCmd.Close acReport, "Graph_report"
       
    End If

    End Sub


    Does the report also print out on paper when you run this code?  It looks to me like the line:

        DoCmd.OpenReport <report name>, acViewNormal

    ... will print the report normally, while the following line:

        DoCmd.OutputTo acOutputReport, <report name>

    ... will open the Output To dialog and let you choose PDF format, as well as the output file name and folder.

    In neither case, I think, is the DoCmd.Close line necessary, though it doesn't cause an error.

    But the posted code doesn't do anything to specifically send the report to a PDF file, so we have to look elsewhere for the problem.

    Are you really sure the report is configured for landscape orientation, and that when you open it in print preview, it comes up in landscape layout?

    What happens if you do this:

        DoCmd.OpenReport "Graph_Report_FieldShifts", acViewPreview
        DoCmd.OutputTo acOutputReport, "Graph_Report_FieldShifts"

    Does that open the report in print preview, and then allow you to output it to PDF?  If so, do both the print preview and the PDF show the report in landscape orientation?

     


    Dirk Goldgar, MS Access MVP
    Access tips: www.datagnostics.com/tips.html
    • Proposed as answer by Bruce Song Thursday, June 2, 2011 3:29 AM
    • Marked as answer by Bruce Song Tuesday, June 7, 2011 12:48 PM
    Monday, May 30, 2011 8:43 PM

All replies

  • I have a dashboard form, in which there is a pdf icon,whenever user click on that pdf icon the access report is get converted into pdf documents.

    Now the problem is that when i open that pdf document it open into potraite view and the graph of the report spilt into two page.

    what i want that the pdf file is open into landscap view ,so that graph able to into view into one page.

    what i do,plz help.


    Is the report itself set for portrait or landscape page layout?  If you open the report in Print Preview mode, do you see it in landscape, or is it portrait?
    Dirk Goldgar, MS Access MVP
    Access tips: www.datagnostics.com/tips.html
    Friday, May 27, 2011 4:11 PM
  • In the print preview pane change portrait to landscape
    • Proposed as answer by KCDW Friday, May 27, 2011 4:19 PM
    • Unproposed as answer by KCDW Friday, May 27, 2011 9:22 PM
    Friday, May 27, 2011 4:16 PM
  • no ,i has already set to landscap in print priview mode
    Friday, May 27, 2011 4:45 PM
  • Make sure your settings in Access for create pdf file are set correctly
    Friday, May 27, 2011 4:59 PM
  • where i can find the setting for that???
    Friday, May 27, 2011 6:45 PM
  • If you are using Access 2007 there should be a tab in the ribbon called Adobe. Typically the third icon will be preferences. This is where you change your settings. Under the settings pane, select Advanced, then near the bottem it asks for the default page size. Try changing this to 11.0 X 8.5 instead of 8.5 X 11.0
    Friday, May 27, 2011 7:09 PM
  • i am using access 2010
     and there is no and ribbon called adobe.
    Friday, May 27, 2011 7:13 PM
  • Even in 2010 if you should have that on the ribbon. perhaps it is an add on


    Wait that should be Acrobat not Adobe

     

    Friday, May 27, 2011 7:50 PM
  • Is there not any coding techiniq to set that required . i am unable to find that add on .

    What i do??

    Friday, May 27, 2011 8:07 PM
  • What coding do you have for the pdf icon now?

    Friday, May 27, 2011 8:20 PM
  • This is the code that i have  written for the click event of pdfIcon

    Private Sub cmdPrintReportPDF_Click()

     

    If Form_Graphs.tab_graph.Value = 2 Then

      DoCmd.OpenReport "Graph_Report_FieldShifts", acViewNormal
        DoCmd.OutputTo acOutputReport, "Graph_Report_FieldShifts"
        DoCmd.Close acReport, "Graph_Report_FieldShifts"

     Else
        DoCmd.OpenReport "Graph_report", acViewNormal
        DoCmd.OutputTo acOutputReport, "Graph_report"
        DoCmd.Close acReport, "Graph_report"
       
    End If

    End Sub

    Friday, May 27, 2011 8:27 PM
  • I do not see a reference to Adobe Acrobat as a program. How do you call adobe to convert?
    Friday, May 27, 2011 9:06 PM
  • I simply write this and this works very well.

    When i click on pdf Icon it automatically start to asked to saved several format.I choose pdf and click save button and it saved.But the report slipt into two page.

    Friday, May 27, 2011 9:19 PM
  • I do not know the answer but it seems to me wherever Access gets the convert to pdf from is where you need to go to change your settings. You might want to look and make sure...

    Under add-ins that Acrobat PDFMaker Office COM Addin is there and I read that in Access 2010 you can turn on and off ribbon tabs. try using help and ask the question...

    view the Acrobat tab on the ribbon

    Also try changing your search to developer Reference next to the word "search"
    Friday, May 27, 2011 9:30 PM
  • thnks
    Friday, May 27, 2011 9:50 PM
  • This is the code that i have  written for the click event of pdfIcon

    Private Sub cmdPrintReportPDF_Click()

     

    If Form_Graphs.tab_graph.Value = 2 Then

      DoCmd.OpenReport "Graph_Report_FieldShifts", acViewNormal
        DoCmd.OutputTo acOutputReport, "Graph_Report_FieldShifts"
        DoCmd.Close acReport, "Graph_Report_FieldShifts"

     Else
        DoCmd.OpenReport "Graph_report", acViewNormal
        DoCmd.OutputTo acOutputReport, "Graph_report"
        DoCmd.Close acReport, "Graph_report"
       
    End If

    End Sub


    Does the report also print out on paper when you run this code?  It looks to me like the line:

        DoCmd.OpenReport <report name>, acViewNormal

    ... will print the report normally, while the following line:

        DoCmd.OutputTo acOutputReport, <report name>

    ... will open the Output To dialog and let you choose PDF format, as well as the output file name and folder.

    In neither case, I think, is the DoCmd.Close line necessary, though it doesn't cause an error.

    But the posted code doesn't do anything to specifically send the report to a PDF file, so we have to look elsewhere for the problem.

    Are you really sure the report is configured for landscape orientation, and that when you open it in print preview, it comes up in landscape layout?

    What happens if you do this:

        DoCmd.OpenReport "Graph_Report_FieldShifts", acViewPreview
        DoCmd.OutputTo acOutputReport, "Graph_Report_FieldShifts"

    Does that open the report in print preview, and then allow you to output it to PDF?  If so, do both the print preview and the PDF show the report in landscape orientation?

     


    Dirk Goldgar, MS Access MVP
    Access tips: www.datagnostics.com/tips.html
    • Proposed as answer by Bruce Song Thursday, June 2, 2011 3:29 AM
    • Marked as answer by Bruce Song Tuesday, June 7, 2011 12:48 PM
    Monday, May 30, 2011 8:43 PM
  • Hi Vikram,

    What's the status of the problem on your side? Have you resolved it yet?

    I test the following code on my side:

    Private Sub btnOutputPDF_Click()
        Dim outputFileName As String
        Dim strReportName As String
        strReportName = "StudentInfo"
        outputFileName = CurrentProject.Path & "\Export_" & Format(Date, "yyyyMMdd") & ".pdf"
        DoCmd.OpenReport strReportName, acViewPreview
        DoCmd.OutputTo acOutputReport, strReportName, acFormatPDF, outputFileName, True
    End Sub

    Just as Dirk said, if we want the output to be landscape, we should set it in Access. Then, we can get what we want.

    Here is the screen shot to set it:

    Hope this helps.

    Best Regards,


    Bruce Song [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, June 2, 2011 4:09 AM
  • I was having a similar problem in Access 2010 - I had some automated reports (invoking Access under the SQL Server Agent job scheduler) using the Access save as PDF function

    DoCmd.OutputTo acOutputReport, strReportName, acFormatPDF, strOutputFileName, FAlse, , , AcExportQualityPrint

    It had been working fine, then I moved to a new server (and from Access 2007 to Access 2010), and they started coming out portrait.  Report previews were portrait.  I found no Access settings for PDF output.  What seemed to fix it, though, was to go to the database pane, right-click one of the reports, select Export > PDF or XPS, then publish it to a PDF.  After doing that, exports from code worked fine.  I'll worry about why this worked some other day.

    
    
    
    
    Friday, January 18, 2013 4:31 PM