Results 1 to 4 of 4
  1. #1
    3 Star Lounger
    Join Date
    Sep 2002
    Location
    London, England
    Posts
    294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Hide unwanted report section (2000)

    I have a report with one group, with a header and footer section that are both printed. I would like to hide the header section of this group (which contains column headings for the detail section) if there are no details printed on the current page. The footer section contains a lot of text and so frequently ends up on a new page with no details. This is fine, but try as I might, I can't stop Access printing the group's header section as well.

    The repeat section property for this header has been set to Yes as the detail section often spans more than one page and needs column headings on each page.

    Ian

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

    Re: Hide unwanted report section (2000)

    Try the following code in the OnFormat event of the group header:

    GroupHeader1.Visible = Not GroupFooter1.WillContinue

    Replace GroupHeader1 and GroupFooter1 by the actual name of the group header and footer sections on your report. The WillContinue property of a section is True if that section will be continued on the next page. Since the code is called in the OnFormat of the group header section, it will use the value of WillContinue from the previous page.

  3. #3
    3 Star Lounger
    Join Date
    Sep 2002
    Location
    London, England
    Posts
    294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Hide unwanted report section (2000)

    Hans, Thanks for the advice. I didn't know about the WillContinue property. It will come in useful.

    However, in this instance I can't get it to work. I have tried the following:

    ' Me.Section(5).Visible = Not Me.Section(6).WillContinue
    ' **** Has no effect

    ' GroupHeader0.Visible = Not GroupFooter0.WillContinue
    ' **** Variable not defined error (for GroupFooter0)

    The report I am working on has only one group which, according to my trusty Getz/Litwin/Gilbert, should be accessible via Me.Section(5) for the header and Me.Section(6) for the footer. Unfortunately this doesn't seem to work.

    Interestingly, when I let intellisense show me my options after typing in Me.group, I can see a GroopFooter1 and a GroupHeader0. As I say, there is only one group on this report, which has both a header and a footer. So I tried:

    Me.GroupHeader0.Visible = Not Me.GroupFooter1.WillContinue

    but this didn't work either. Is it possible that Access has got its report sections in a muddle? Is there an easy way out if it has?

    Ian

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

    Re: Hide unwanted report section (2000)

    Ian,

    I must admit that I tested this code in a report with more than one group header. I just tried it on a report with only one group header; the code caused the report to "hang". I was able to get it working again by creating a dummy header section before the header section that has to be hidden/unhidden. The field/expression for this section is =1, and the dummy header must be visible and have a non-zero height (the height can be very small, though).

    I have attached a zipped Access 97 database with a demo report; it is based on one of the examples from the Report Samples database from Microsoft. To get a footer that can extend over two pages, I used a stupid narrow text box with a large font; this is just for demonstration purposes.

    Note: if you click in a blank part of a report section (in design view), you will see the actual name of the section in the Object dropdown in the Formatting (Form/Report) toolbar and in the caption of the Properties window.
    Attached Files Attached Files

Posting Permissions

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