need to show subreport with no data (1 Viewer)

mcw21j

Registered User.
Local time
Today, 13:35
Joined
Nov 23, 2013
Messages
26
good day, good people!
i have a main report with several subreports. Some subreports have other nested subreports. all of the reports and subreports are based on queries. when a query returns no values, i would still like for the reports and subreports to display in print preview. (currently, they display in report view but not in print preview.)

I tried a few things:
1) i set all report section can shrink options to "No" - (this did not help)

2) i set the can shrink options for all textbox controls, within each report section , to "No" - (this did not help)

3) i moved all controls from the details section of the subreport to the report header section - (when I did this, I got the subreport to show in print preview when the query for a single subreport returns no values…but when i have a subreport with nested subreports that have no value, none of them show up in print preview)

i've searched high and low and can't find an answer...moving the controls from the details to the report header was the best thing i could find, but again, this only works with a single subreport and not with multiple nested subreports.

any help is appreciated.
 

mcw21j

Registered User.
Local time
Today, 13:35
Joined
Nov 23, 2013
Messages
26
This was an option i was playing with at the end of the day yesterday. i've used this method before (placing a text box behind a subreport which would display when the subreport has no data) but i assumed that there would be something more elegant. my method seems so "fudgy". i mean, i guess it works, right?

with as many views as this thread has and with only 1 reply, i guess there really isn't a better way to do this.
 

GinaWhipp

AWF VIP
Local time
Today, 16:35
Joined
Jun 21, 2011
Messages
5,899
It does and it's the only way I have ever heard of working.
 

BlueIshDan

☠
Local time
Today, 17:35
Joined
May 15, 2014
Messages
1,122
Maybe have a Label in the header of the report and in the onload of the report have something like this
Code:
        Dim rs As Recordset: Set rs = CurrentDb.OpenRecordset (Me.RowSource)
        lblNoData.Visible = (rs.RecordCount = 0)
 

mcw21j

Registered User.
Local time
Today, 13:35
Joined
Nov 23, 2013
Messages
26
Thanks Dan!

I went with the hiding labels option. It works great with 1 level of nested subreport but I have 2 nested levels (subrpt_3, nested in subrpt_2; and then subrpt_2 is nested in subrpt_1).

This is the code that works where subrpt_3 is contained within subrpt_2 (this is the on load event for subrpt_2):

------------------------------------
Private Sub Report_Load()
If Me.subrpt_3.Report.HasData = False Then
Me.Label0.Visible = True
Me.Label1.Visible = True
Else
Me.Label0.Visible = False
Me.Label1.Visible = False
End If
End Sub
------------------------------------

now what do you all think the syntax should be if "subrpt_2" is actually a subreport within "subrpt_1"?

Thanks in advance for the brain power.
 

GinaWhipp

AWF VIP
Local time
Today, 16:35
Joined
Jun 21, 2011
Messages
5,899
Heh, I missed that post... That is clever BlueIshDan!
 

mcw21j

Registered User.
Local time
Today, 13:35
Joined
Nov 23, 2013
Messages
26
well, to update...
i couldn't get the multi-level nested subreports to show the way i wanted.

instead, i added a parameter value to the underlying queries, which created a dummy record in the resulting query. the record had no other data except for the dummy parameter value.

since the subreports now had a dummy record, the subreport would show the way i wanted.

a cheap solution but it ended up working just right.
 

BlueIshDan

☠
Local time
Today, 17:35
Joined
May 15, 2014
Messages
1,122
Thanks Dan!

I went with the hiding labels option. It works great with 1 level of nested subreport but I have 2 nested levels (subrpt_3, nested in subrpt_2; and then subrpt_2 is nested in subrpt_1).

This is the code that works where subrpt_3 is contained within subrpt_2 (this is the on load event for subrpt_2):

------------------------------------
Private Sub Report_Load()
If Me.subrpt_3.Report.HasData = False Then
Me.Label0.Visible = True
Me.Label1.Visible = True
Else
Me.Label0.Visible = False
Me.Label1.Visible = False
End If
End Sub
------------------------------------

now what do you all think the syntax should be if "subrpt_2" is actually a subreport within "subrpt_1"?

Thanks in advance for the brain power.

If you have it so that each report loads it's own built in label, it should work on it's own right?

Me.Label0.Visible = Not Me.HasData

Something along those lines.
 

Users who are viewing this thread

Top Bottom