Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 2004
    Location
    NY
    Posts
    113

    Unanswered: Display message with subform

    Hi,

    I have a main form that has a subform. When the subform has no data the main form will display a label.

    I am getting a 2455 error message.
    Code:
    If Me![srptDiscrepency].Report.HasData Then
           Label16.Visible = False
    Else
            Label16.Visible = True
    End If
    ======================
    Levent
    Access 3

  2. #2
    Join Date
    May 2004
    Location
    New York State
    Posts
    1,178
    The HasData property is only valid for reports, not for forms. I think you mean that you have a main report and subreport. Is that what you mean?

    Also, which line is giving you the error, the if... statement or another line?

    Sam

  3. #3
    Join Date
    Aug 2004
    Location
    NY
    Posts
    113
    Yes, it is a subreport. The IF statement is giving me the problem. So if that subreport has no data then that label will be visible indicating no data.
    ======================
    Levent
    Access 3

  4. #4
    Join Date
    May 2004
    Location
    New York State
    Posts
    1,178
    To start off with, is srptDiscrepency spelled correctly? The correct spelling in English is with an 'a', as in srptDiscrepancy.

    Sam

  5. #5
    Join Date
    Jun 2007
    Location
    Maitland NSW,Australia
    Posts
    388

    Display Message

    Does your label need to be on the main report?

    1. You could put your label on the report footer of your subreport.
    2. Set the Visible property of the label to No.
    3. Using the NoData event of the subreport insert the following code.
    Private Sub Report_NoData(Cancel As Integer)
    Label16.Visible = True
    End Sub

    Using your example your syntax maybe incorrect the correct format is
    [main report name]![sub report name]![field name on the subreport]

Posting Permissions

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