Report Not Visible

Leesha
BronzeLounger
Posts: 1488
Joined: 05 Feb 2010, 22:25

Report Not Visible

Post by Leesha »

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

User avatar
HansV
Administrator
Posts: 78465
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Report Not Visible

Post by HansV »

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.
Best wishes,
Hans

Leesha
BronzeLounger
Posts: 1488
Joined: 05 Feb 2010, 22:25

Re: Report Not Visible

Post by Leesha »

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

Leesha
BronzeLounger
Posts: 1488
Joined: 05 Feb 2010, 22:25

Re: Report Not Visible

Post by Leesha »

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.

User avatar
HansV
Administrator
Posts: 78465
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Report Not Visible

Post by HansV »

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:

Code: Select all

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    Me.MyLabel.Visible = Not Me.MySubReport.Report.HasData
End Sub
where MyLabel is the name of the label, and MySubReport is the name of the subreport as a control on the main report.
Best wishes,
Hans

Leesha
BronzeLounger
Posts: 1488
Joined: 05 Feb 2010, 22:25

Re: Report Not Visible

Post by Leesha »

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

User avatar
HansV
Administrator
Posts: 78465
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Report Not Visible

Post by HansV »

It worked in my test database, so I'm afraid I'd have to see yours...
Best wishes,
Hans

Leesha
BronzeLounger
Posts: 1488
Joined: 05 Feb 2010, 22:25

Re: Report Not Visible

Post by Leesha »

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.

User avatar
HansV
Administrator
Posts: 78465
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Report Not Visible

Post by HansV »

I'm confused. The main report does not contain a label with a text as suggested, nor the code as suggested.
Best wishes,
Hans

Leesha
BronzeLounger
Posts: 1488
Joined: 05 Feb 2010, 22:25

Re: Report Not Visible

Post by Leesha »

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.

User avatar
HansV
Administrator
Posts: 78465
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Report Not Visible

Post by HansV »

Thanks. The label is behind the subreport srptClientPossibleEmotionalCauseMultiple, but in your code, you look at srptClientPossibleEmotionalCauseAll.
Change the line

Code: Select all

    Me.lblNoData.Visible = Not Me.srptClientPossibleEmotionalCauseAll.Report.HasData
to

Code: Select all

    Me.lblNoData.Visible = Not Me.srptClientPossibleEmotionalCauseMultiple.Report.HasData
Best wishes,
Hans

Leesha
BronzeLounger
Posts: 1488
Joined: 05 Feb 2010, 22:25

Re: Report Not Visible

Post by Leesha »

:groan: 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