Results 1 to 7 of 7
  1. #1
    3 Star Lounger
    Join Date
    Dec 2000
    Location
    Manassas, Virginia, USA
    Posts
    363
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Print a Pivot Table from Code (Access 2002, SP3)

    I have a pivot table that I am opening through the following code: DoCmd.OpenQuery "HomelessStudents" acViewPivotTable

    The next thing I would like the code to do is print the pivot table. I tried the following code: DoCmd.RunCommand acCmdPrint

    but this simply opens the print dialog box and the user has to click OK. Is there any way to modify the command so that it prints without user intervention?
    Judy Jones, Computer Training Specialist
    Manassas, Virginia

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Print a Pivot Table from Code (Access 2002, SP3)

    Try DoCmd.PrintOut.

  3. #3
    3 Star Lounger
    Join Date
    Dec 2000
    Location
    Manassas, Virginia, USA
    Posts
    363
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Print a Pivot Table from Code (Access 2002, SP3)

    When I replaced my DoCmd code with yours I get error #2585 This action can't be carried out while processing a form or report event
    Judy Jones, Computer Training Specialist
    Manassas, Virginia

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Print a Pivot Table from Code (Access 2002, SP3)

    Where is the code you mention? It works OK in the On Click event of a command button on a form.

  5. #5
    3 Star Lounger
    Join Date
    Dec 2000
    Location
    Manassas, Virginia, USA
    Posts
    363
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Print a Pivot Table from Code (Access 2002, SP3)

    I am calling the code from a command button. I deleted the code and recreated it and it is now working. I must have typed something wrong the first time.

    One other question, is there any way to set my margins to .25 on the fly without user intervention.
    Judy Jones, Computer Training Specialist
    Manassas, Virginia

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Print a Pivot Table from Code (Access 2002, SP3)

    Printing queries is meant for a quick one-off or for testing purposes, not for production purposes. Page setup for a query is not exposed in the object model, and it is not stored either.

  7. #7
    3 Star Lounger
    Join Date
    Dec 2000
    Location
    Manassas, Virginia, USA
    Posts
    363
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Print a Pivot Table from Code (Access 2002, SP3)

    Thanks for all your help. The user will just have to cut and paste the printout together.
    Judy Jones, Computer Training Specialist
    Manassas, Virginia

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •