Results 1 to 5 of 5
  1. #1
    2 Star Lounger
    Join Date
    Feb 2003
    Posts
    144
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Hid subreport (2002)

    I need to hide a subreport if it contains no data, the subreport is located in the detail section of the main report. I have the following procedure:

    Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

    Me.srptItmsUnrcrd.Report.Visible = Me.srptItemsUnrcrd.Report.HasData

    End Sub

    This generates a compile error that the method or property is valid. Any help would be appreciated.

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

    Re: Hid subreport (2002)

    The Visible property is a property of the subreport control, not of the subreport as a report. Try

    Me.srptItmsUnrcrd.Visible = Me.srptItemsUnrcrd.Report.HasData

  3. #3
    2 Star Lounger
    Join Date
    Feb 2003
    Posts
    144
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Hid subreport (2002)

    Thanks Hans. That worked, but created an additional problem. If the subreport in the detail section has data I need to force a new page. I can get that to work, but now page numbers are off (Page 5 of 6 Pages). Here's the code in the on format event of the detail section.

    Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

    Me.srptItmsUnrcrd.Visible = Me.srptItmsUnrcrd.Report.HasData
    Me.Detail.ForceNewPage = IIf(Me.srptItmsUnrcrd.Report.HasData = -1, 1, 0)

    End Sub

    What am I not understanding here? Thanks in advance...

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

    Re: Hid subreport (2002)

    I don't understand why that happens either. But perhaps the following will work better:
    - Set the Force New Page property of the Detail section to None.
    - Place a Page Break control in the detail section just above the subreport.
    - Name it (for example) pgBreak.
    - Replace the line that sets ForceNewPage with the following line:

    Me.pgBreak.Visible = Me.srptItmsUnrcrd.Report.HasData

  5. #5
    2 Star Lounger
    Join Date
    Feb 2003
    Posts
    144
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Hid subreport (2002)

    Hans, dude, you are my hero! That works perfectly...

Posting Permissions

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