Results 1 to 8 of 8
  1. #1
    Eddy Sincere is offline Competent Performer
    Windows 10 Access 2013
    Join Date
    Jul 2014
    Location
    Carson City, NV
    Posts
    114

    Subreport visible/not visible when a box is checked


    I have a primary report with multiple subreports. One of the subreports needs to be hidden (invisible) when a check-box on the primary report is unchecked. Basically, the user can choose whether to print the subreport.

    There are quite a few discussions about making the subreport visible when it contains (or doesn't) information, which is a different situation. Any help would be appreciated.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    This should help:

    http://www.baldyweb.com/ConditionalVisibility.htm

    The report has to be in Report view to be interactive; Preview won't work.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Eddy Sincere is offline Competent Performer
    Windows 10 Access 2013
    Join Date
    Jul 2014
    Location
    Carson City, NV
    Posts
    114
    Thanks for the VBA.

    Where should the event be placed?

    Primary report?
    On Current?
    On Load?
    etc.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    I'd start with the after update event of the checkbox.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    Eddy Sincere is offline Competent Performer
    Windows 10 Access 2013
    Join Date
    Jul 2014
    Location
    Carson City, NV
    Posts
    114
    BOOM! Fixed it! Here's the VBA I dropped into the On Load event of the primary form:



    Private Sub Report_Load()
    If Me.CompBOM = -1 Then
    Me.SRCOMPBOM.Visible = True
    Else
    Me.SRCOMPBOM.Visible = False
    End If
    End Sub

    Thanks for the help!

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Glad you got it working. I take it you didn't want to toggle the visibility if they checked/unchecked the box?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    Eddy Sincere is offline Competent Performer
    Windows 10 Access 2013
    Join Date
    Jul 2014
    Location
    Carson City, NV
    Posts
    114
    Correct. The check box just indicates if the information will printed on the report, not necessarily to show/hide information on the form. There's a lot of information on the form that prints on the report and, in some situations, some of it may be unnecessary. So I just wanted the user to have the ability to choose what gets printed depending on their preference.

  8. #8
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    Alternatively, the checkbox could be on the form used to open the report so that the report could then be viewed in print preview with or without the subreport visible

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

Similar Threads

  1. Replies: 5
    Last Post: 08-14-2017, 02:19 AM
  2. Replies: 16
    Last Post: 03-26-2015, 08:35 PM
  3. Forms, text box only visible when yes/no field checked
    By Remillard in forum Programming
    Replies: 6
    Last Post: 04-15-2013, 12:59 PM
  4. Setting visible property of subreport?
    By GaryElwood in forum Reports
    Replies: 1
    Last Post: 09-23-2011, 07:49 PM
  5. Replies: 2
    Last Post: 01-06-2011, 04:38 AM

Tags for this Thread

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