Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2008
    Posts
    2

    Unanswered: Hiding a Subreport

    Hello,

    I have a report with the following code in "On Open" event procedure:

    Private Sub Report_Open(Cancel As Integer)
    If Me!CONTROL_NAME = "NO" Then
    Me.SUBREPORT_NAME.Visible = False
    Else
    Me.SUBREPORT_NAME.Visible = True
    End If
    End Sub

    There is a field on the main report called "CONTROL_NAME" that populates with "YES" or "NO" depending on whether or not I want the subreport to be visable. However I receive the following error when the report opens:

    "You entered an expression that has no value"

    Any help would be appreciated.

    Thank you

  2. #2
    Join Date
    Feb 2004
    Posts
    137
    This code does not belong in the Report_Open event. This code belongs in the Format event of the section in which the Subreport object resides. For instance, if the Subreport object is in the Detail section of the report, you would use the Detail_Format event, thus:
    Code:
    Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    
        If Me!CONTROL_NAME = "NO" Then
            Me.SUBREPORT_NAME.Visible = False
        Else
            Me.SUBREPORT_NAME.Visible = True
        End If
    
    End Sub

  3. #3
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    And why not use boolean Yes and No, rather than a string based "Yes" and "No"? Then you can just use a checkbox or option button.
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  4. #4
    Join Date
    Feb 2008
    Posts
    2
    Thank you...it worked!

Posting Permissions

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