Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Oct 2004
    Location
    Minnesota, USA
    Posts
    151
    Thanks
    0
    Thanked 0 Times in 0 Posts

    No Data in Subreports (Office 2000 / 2003)

    I have a report with five subreports. On any given day, one or more of the subreports may not have data. I would like a message to print on the report that there is no data vs. the space being blank so the user knows there was no data and it's not an error.

    I have a label containing the message I want to print. On the subreport, in the no data event, I have it hiding the data fields and displaying the label when there is no data.

    I think the "no data" event won't work on a subreport, but I cannot remember where I need to put the code in the "master" report. Is it in the OnFormat event of the detail section? And I would have to refer to each subreport separately I presume? How would I do that, that is, how do I detect there's not data in the subreport?

    Thanks for your help.

    Nancy

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

    Re: No Data in Subreports (Office 2000 / 2003)

    You can use the HasData property of the subreport. Put code in the On Format event of the section that contains the subreport. For example, if the subreport is in the Detail section:

    Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    If Me.SubReportControl.Report.HasData Then
    Me.LabelName.Caption = ""
    Else
    Me.LabelName.Caption = "There are no data to be displayed."
    End If
    End Sub

    where LabelName is the name of the label and SubReportControl is the name of the subreport as a control on the main report; this is not necessarily the same as the name of the subreport in the database window.

  3. #3
    2 Star Lounger
    Join Date
    Oct 2004
    Location
    Minnesota, USA
    Posts
    151
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: No Data in Subreports (Office 2000 / 2003)

    Thanks, Hans.

    I was missing Report in front of HasData.

    I appreciate your quick response.

    Nancy

Posting Permissions

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