Results 1 to 6 of 6
  1. #1
    dssrun is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Oct 2010
    Posts
    83

    Hide subreports when null

    I know someone has answered this question before but i couldn't find a good answer. I have a subreport linked in the footer of a group, so there are about 5 different instance of just one subreport. I want to hide only the instances where that subreport is null. Microsoft help has the code below to hide a subreport when there is no data. However, this hides all subreport instances in each footer when in fact there is data since the first instance has no data. Is there a way to use a for each statement here to cycle through each instance of the subreports or is there another way to accomplish this? Thanks.



    Code:
    Me!rptsubReason.Visible = Me!rptsubReason.Report.HasData

  2. #2
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    Did you put it in the ON FORMAT event of the group footer?

  3. #3
    NTC is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2009
    Posts
    2,392
    you have to make it visible too.

    once non visible, always non visible (and vice versa) so you have to put in a statement for both as it compares each page as it builds.....

    hope it helps.

  4. #4
    dssrun is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Oct 2010
    Posts
    83
    Does that mean I need a statement like
    Code:
        If Me!rptsubReason.Report.HasData = True Then
            Me!rptsubReason.Visible = True
        Else
            Me!rptsubReason.Visible = False
    End if

  5. #5
    dssrun is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Oct 2010
    Posts
    83
    I feel stupid, I was testing this out when I hit "report" or "layout" and it only works when you hit print preview or when you are ready to export the report. This seems to do the trick in the GroupFooter Format Event

    Code:
    Me!rptsubReason.Visible = Me!rptsubReason.Report.HasData

  6. #6
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    Quote Originally Posted by NTC View Post
    you have to make it visible too.
    NTC:

    This code:

    Me!rptsubReason.Visible = Me!rptsubReason.Report.HasData

    Does just that - it makes it visible when it has data and not visible when it doesn't.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Subreports - Different
    By frousseau in forum Reports
    Replies: 1
    Last Post: 09-07-2010, 05:14 PM
  2. Using Subreports
    By jonesy29847 in forum Access
    Replies: 5
    Last Post: 04-20-2010, 11:16 AM
  3. Subreports with no values
    By vCallNSPF in forum Reports
    Replies: 6
    Last Post: 12-10-2009, 10:51 AM
  4. PivotGraph Subreports
    By smokeybill08 in forum Reports
    Replies: 1
    Last Post: 06-10-2009, 11:33 AM
  5. Hiding subreports
    By aouellette in forum Reports
    Replies: 0
    Last Post: 09-12-2008, 08:02 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums