Results 1 to 6 of 6
  1. #1
    RMAL is offline Novice
    Windows 10 Office 365
    Join Date
    Feb 2023
    Posts
    6

    Subreport not showing on master report it has when no records

    I have a Master Report that has 4 subreports. The Master report actually has nothing other than a header and the 4 subreports in its details section. In that sense, the Master is not much more than a container for the subreports.



    My intent is that each of the 4 subreports would print in the order they appear in the detail section of the master report, with no page break between them -- that is, when subreport #1 finishes showing all its records, start showing the 2nd subreport and so on. I have this working just fine.

    My problem is when any of the subreports has no data, the entire subreport doesn't show when the master is run -- I just see an annoying gap with nothing on it, and then the next subreport starts (assuming it has records to show). What I would like to have happen is this: If any of the 4 subreports has no data, show that subreport's Report Header, perhaps with a new label I can now make visible that says "No Data" or something similar.

    Many thanks in advance

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,914
    Look at the NoData event of the subreport
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,791
    AFAIK, sub report control is invisible if no data and there is nothing you can do to change that. Most suggestions seem to be about making a textbox(es) or label(s) visible in its place when there's no data.

    EDIT- of course, using OnNoData event still applies.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  4. #4
    RMAL is offline Novice
    Windows 10 Office 365
    Join Date
    Feb 2023
    Posts
    6
    It looks like the NODATA event cannot be triggered from a subreport, at least that's what Microsoft says (See the Remarks section here: https://learn.microsoft.com/en-us/of....report.nodata )
    If I just run my report by itself, then the NODATA event is triggered. But when I run the master report using that same report as a subreport within the master report, the event is not triggered. Nor can I use the NoData event from the master report -- it has no record source to check (just a bunch of sub reports) so the event cannot be triggered.

    If there's a solution to this, it has to come from somewhere else.

  5. #5
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,791
    OK, I stand corrected. However, if sub report control (thus the report it's supposed to hold) doesn't show, then your OP has the answer (except you can't show the sub header). But you can show controls that might replicate it, or just a label stating there's no data to show for "whatever"? So in the main report Load event (untested):
    If Me.subReportName.Report.HasData = False Then SomeLabelName.Visible = True
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  6. #6
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,114
    Could you please show us the master and the four subreports in design view? Can you try to make the subreports really short (height-wise) and close together so if one is missing you don't get a big gap (set the Can Grow property to Yes)?

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

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

Similar Threads

  1. Replies: 4
    Last Post: 08-07-2017, 08:09 AM
  2. Replies: 2
    Last Post: 03-31-2017, 08:40 AM
  3. Showing a subreport only once in a report
    By bfryxell in forum Reports
    Replies: 1
    Last Post: 05-07-2015, 11:33 PM
  4. Simple report with master/detail records
    By dsajones in forum Reports
    Replies: 2
    Last Post: 06-21-2012, 04:36 PM
  5. Replies: 4
    Last Post: 03-14-2011, 11:12 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