Results 1 to 3 of 3
  1. #1
    New Lounger
    Join Date
    Apr 2002
    United Kingdom
    Thanked 0 Times in 0 Posts

    Printing a certain page in a report (Access 97 SR-2)

    I have a report which has 26 pages - the pages are basically a list of Establishment Names and their post codes. One of the pages contains a highlighted line using me.detail.backcolor = rgb etc, etc......
    The report is produced by clicking on a button in a form which automatically sends the report to a printer.

    My problem is that I only want to print the page that contains the highlighted line, not all 26 pages.

    Thanks for any help!

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Sacramento, California, USA
    Thanked 1 Time in 1 Post

    Re: Printing a certain page in a report (Access 97 SR-2)

    It's perfectly possible to print a report that only contains specified records; but pages for reports are determined on the fly as the report is formatted, so you can't just tell Access in code to print page whatever of report such and such. Can you explain more about this highlighted record? How does it get highlighted, and what are you actually trying to print?

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Thanked 28 Times in 28 Posts

    Re: Printing a certain page in a report (Access 97 SR-2)

    I assume that you want to print the entire page with the highlighted line. If you wanted to print just the highlighted line, you could pass a WhereCondition argument to DoCmd.OpenReport.

    As Charlotte has remarked, reports are formatted on the fly, so if you open a report in Normal view (=send directly to printer), there is no way to tell Access to print a specific page.

    If you open the report in Preview mode, there are several options.
    <UL><LI>The easiest, of course, is to let the user print a specific page interactively.
    <LI>If the highlighted line is on a fixed page, say on page 6, you can use

    DoCmd.PrintOut acPages, 6, 6

    <LI>If you don't know on which page the highlighted line will occur, the following may do what you want.
    1. <LI>Define a global variable in a standard module, say

      Public lngPage As Long

      <LI>In the OnOpen event of the report, reset lngPage:

      lngPage = 0

      <LI>In the OnFormat event of the Detail section, set lngPage to the page where you highlight the line:

      If some condition Then
      Me.Detail.BackColor = Rgb(192, 192, 192)
      lngPage = Page
      End If

      <LI>Make sure you have a reference to Pages in the page footer - this forces Access to format the whole report once before displaying it. If you omit this, lngPage will remain 0 until the user manually browses to the page with the highlighted line.
      <LI>Open the report like this:

      DoCmd.OpenReport "rptMyReport", acViewPreview
      DoCmd.PrintOut acPages, lngPage, lngPage

Posting Permissions

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