Results 1 to 7 of 7
  1. #1
    Star Lounger
    Join Date
    Jan 2002
    Location
    Washington State
    Posts
    69
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Printing Specific Page of Report (A2K)

    Hi all!

    I have a report that is always three pages in length.

    Most of the time the user needs to print all three pages, but occasionally they only need a specific page.

    Currently I have three different versions of this report. One report is all three pages. Another is just page 1. And the last report is just page two. The user invokes the requested report by clicking on a command button. It's worked this way for years. My biggest beef with this is every time I make a design change on one report I have to repeat my steps on the other two reports. It's time to make a smart change!

    Is it possible to use the command buttons to determine which pages of the report need to be printed?

    Thanks!
    Sam

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

    Re: Printing Specific Page of Report (A2K)

    You could use code like this to print a specific page of a report:

    Const strReport = "rptSomething"
    Dim intPage As Integer
    intPage = 2 ' you could set this depending on a value selected on the form.
    DoCmd.SelectObject acReport, strReport, True
    DoCmd.PrintOut acPages, intPage, intPage

  3. #3
    Star Lounger
    Join Date
    Jan 2002
    Location
    Washington State
    Posts
    69
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Printing Specific Page of Report (A2K)

    Thanks for the idea, Hans!

    Is there anyway to display the Print Dialog box using DoCmd.PrintOut? It appears to directly print the report to the default printer.

    I like to give my users the option to select a printer. Here's how I handle it:

    Private Sub cmdPrint_Click()
    varPrint = True 'Fill the Public Variable
    DoCmd.OpenReport "rptSomething", acViewPreview
    End Sub

    Private Sub Report_Page()
    If varPrint = True Then
    DoCmd.RunCommand acCmdPrint
    DoCmd.Close acReport, me.Name
    End If
    End Sub

    Is there a way to integrate your idea with the setup I have?

    Thanks!
    Sam

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

    Re: Printing Specific Page of Report (A2K)

    Since you display the print dialog anyway using RunCommand acCmdPrint, the user can specify the page(s) to print there too - no additional code needed.
    Attached Images Attached Images
    • File Type: png x.png (52.2 KB, 1 views)

  5. #5
    Star Lounger
    Join Date
    Jan 2002
    Location
    Washington State
    Posts
    69
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Printing Specific Page of Report (A2K)

    Oh, you're absolutely right, of course!

    However, you overestimate the computer skills of my average user. Ha!

    Is there a way to set the page numbers in the Print Dialog box based on the command button pressed? Does this mean using PrintDev?

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

    Re: Printing Specific Page of Report (A2K)

    If they're not able to enter the number 3 in a box, they won't be able to select a printer either, so you'd be better off using the code I posted earlier!

    You might try using SendKeys to enter information in the boxes on the dialog, but that's not very dependable.

  7. #7
    Star Lounger
    Join Date
    Jan 2002
    Location
    Washington State
    Posts
    69
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Printing Specific Page of Report (A2K)

    Ha! Good one!

    Okay, thanks for the suggestions! Enjoy your weekend!

    Sam

Posting Permissions

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