Results 1 to 5 of 5
  1. #1
    Josh330 is offline Novice
    Windows 10 Access 2016
    Join Date
    Apr 2023
    Posts
    12

    How to hide subreport based on control in main report


    Hi everyone. I have been researching something for days and cannot seem to find the right answer. I have a report called Names. In that report is a combo box called Place. I have a subreport called Specs. I am trying to make the Specs subreport hidden based on Place being "USA". I have been able to get this to work using forms where I have successfully hidden a subform. I cannot seem to do it in reports. Can anyone suggest the proper VBA code? Thanks!
    Josh

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    What is your code? What event did you use?

    Do you want this display dynamic for each record? Usually, code must be in Format or Print event of section subreport is in.

    If you want to provide db for analysis, follow instructions at bottom of my post.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Josh330 is offline Novice
    Windows 10 Access 2016
    Join Date
    Apr 2023
    Posts
    12
    Hi June. Below is the code I put into the On Load event of the main report. Nothing seems to happen - the Specs subreport is still visible.
    Thanks.
    And, yes, need it to be dynamic for each record.

    Private Sub Report_Load()


    If Reports!Name!Place = "USA" Then
    Me.Specs.Visible = False
    Else
    Me.Specs.Visible = True
    End If


    End Sub

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Then try what I already suggested.

    Subreport is in Detail section?

    Is Specs name of subreport container?

    Even if not visible, subreport still uses space.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    Josh330 is offline Novice
    Windows 10 Access 2016
    Join Date
    Apr 2023
    Posts
    12
    Your suggestion worked. I put the code in the On Format event of the Details section. In Print Preview the subreport Specs is now hidden. I tried the On Print event, but got a result that was a bit wonky. Thanks so much for your help!

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

Similar Threads

  1. Replies: 7
    Last Post: 04-16-2018, 07:43 PM
  2. Replies: 2
    Last Post: 10-07-2016, 04:50 PM
  3. Replies: 2
    Last Post: 03-31-2015, 03:32 AM
  4. Replies: 1
    Last Post: 04-15-2013, 10:02 AM
  5. Subreport with criteria from main report
    By Evilferret in forum Reports
    Replies: 1
    Last Post: 08-15-2012, 03:19 PM

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