Hi,
I have a report that has multiple subreports. It is all working fine. The issue I'm running into is that when a subreport doesn't have data it doesn't show in the report. This is fine. The issue is that I need there to be a statement in the place where the subreport would be that states that there is no data for the subreport. I've tried all sorts of things but nothing is working. Is this possible?
Thanks,
Leesha
Report Not Visible
-
- Administrator
- Posts: 78558
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Report Not Visible
Create a label on the main report with caption "Nothing to see here. Move along, please." (or similar).
Place it over (on top of) the subreport, then click Send to Back on the Arrange tab of the ribbon.
Set the Can Shrink property of the subreport control to Yes.
Place it over (on top of) the subreport, then click Send to Back on the Arrange tab of the ribbon.
Set the Can Shrink property of the subreport control to Yes.
Best wishes,
Hans
Hans
-
- BronzeLounger
- Posts: 1488
- Joined: 05 Feb 2010, 22:25
Re: Report Not Visible
You know I thought about doing something like this but figured I'd check with you first to see if there was another option.
Thanks Hans, i really appreciate it.
Leesha
Thanks Hans, i really appreciate it.
Leesha
-
- BronzeLounger
- Posts: 1488
- Joined: 05 Feb 2010, 22:25
Re: Report Not Visible
Back again. I must be missing something. The label bleeds through when the report opens. Its as if the report back color is set to transparent. It doesn't bleed through if I view it in report view but if I look at it in print preview it bleeds through.
-
- Administrator
- Posts: 78558
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Report Not Visible
Add an On Format event procedure for the section of the main report that contains the subreport.
For example, if it is the Detail section:
where MyLabel is the name of the label, and MySubReport is the name of the subreport as a control on the main report.
For example, if it is the Detail section:
Code: Select all
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Me.MyLabel.Visible = Not Me.MySubReport.Report.HasData
End Sub
Best wishes,
Hans
Hans
-
- BronzeLounger
- Posts: 1488
- Joined: 05 Feb 2010, 22:25
Re: Report Not Visible
This is the code I've got based on your suggestions above. I'm not getting any errors, however the label doesn't show at all. i took out the second line of code that was already on the format event but that didn't make a difference.
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Me.lblNoData.Visible = Not Me.srptClientPossibleEmotionalCauseAll.Report.HasData
Me.srptClientPossibleEmotionalCauseAll.Visible = Forms!FRMSWITCHBOARD!txtDetail = "Summary With Detail"
End Sub
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Me.lblNoData.Visible = Not Me.srptClientPossibleEmotionalCauseAll.Report.HasData
Me.srptClientPossibleEmotionalCauseAll.Visible = Forms!FRMSWITCHBOARD!txtDetail = "Summary With Detail"
End Sub
-
- Administrator
- Posts: 78558
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Report Not Visible
It worked in my test database, so I'm afraid I'd have to see yours...
Best wishes,
Hans
Hans
-
- BronzeLounger
- Posts: 1488
- Joined: 05 Feb 2010, 22:25
Re: Report Not Visible
Here you go. This is really stripped down to allow upload but the result is the same.
You do not have the required permissions to view the files attached to this post.
-
- Administrator
- Posts: 78558
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Report Not Visible
I'm confused. The main report does not contain a label with a text as suggested, nor the code as suggested.
Best wishes,
Hans
Hans
-
- BronzeLounger
- Posts: 1488
- Joined: 05 Feb 2010, 22:25
Re: Report Not Visible
Ugh! So sorry Hans. I kept getting an error that I couldn't pull the report into the DB I was doing for you and I ended up pulling in from my earlier backup and the changes weren't in it. I'm uploading again and I believe this is correct.
You do not have the required permissions to view the files attached to this post.
-
- Administrator
- Posts: 78558
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Report Not Visible
Thanks. The label is behind the subreport srptClientPossibleEmotionalCauseMultiple, but in your code, you look at srptClientPossibleEmotionalCauseAll.
Change the line
to
Change the line
Code: Select all
Me.lblNoData.Visible = Not Me.srptClientPossibleEmotionalCauseAll.Report.HasData
Code: Select all
Me.lblNoData.Visible = Not Me.srptClientPossibleEmotionalCauseMultiple.Report.HasData
Best wishes,
Hans
Hans
-
- BronzeLounger
- Posts: 1488
- Joined: 05 Feb 2010, 22:25
Re: Report Not Visible
As you can tell I'm horrid at proofing my own code, especially when I've been looking at it for hours! Thanks so much. I'm good to go again!
Leesha
Leesha