Solved

How to hide subreport label if subreport has no data

Posted on 2012-04-10
9
2,765 Views
Last Modified: 2012-04-16
I'm trying to hide the subreport label if there is no data in the subreport.

I've researched three solutions on EE and none seem to work for me.

the subreport is a thin line with "Can Grow", that part works great.

I put the label in the sub-report header but it displays every time even if there is no data.

I tried detail_format function also to no avail . . .

Then I tried
Private Sub Report_Current()

    If Me.rptPositionsByCandidate.Report.HasData = True Then
       
        Me.Candiate_Other.Visible = True
    Else
        Me.Candiate_Other.Visible = False
    End If

End Sub

from here , still no luck - the subreport label prints every time.

see attached, run the first report
Candidates-EE.accdb
0
Comment
Question by:Alaska Cowboy
  • 5
  • 2
  • 2
9 Comments
 
LVL 21

Assisted Solution

by:Boyd (HiTechCoach) Trimmell, Microsoft Access MVP
Boyd (HiTechCoach) Trimmell, Microsoft Access MVP earned 350 total points
ID: 37830089
Try this in the on format event for the section with the label on the parent report:

Me.Candiate_Other.Visible = Me.rptPositionsByCandidate.Report.HasData 

Open in new window

0
 
LVL 74

Assisted Solution

by:Jeffrey Coachman
Jeffrey Coachman earned 150 total points
ID: 37830114
0
 
LVL 21

Assisted Solution

by:Boyd (HiTechCoach) Trimmell, Microsoft Access MVP
Boyd (HiTechCoach) Trimmell, Microsoft Access MVP earned 350 total points
ID: 37830137
I did not see that you had an attachment.   This new site skin is really hard for me to see. Poor contrasts in colors.

It was really simple to fix. I just moved the label the the Sub report's Report Header setion. No VBA code needed. Acvess will handle it automatically

See attached
Candidates-EE-HiTechCoach.accdb
0
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
LVL 1

Author Comment

by:Alaska Cowboy
ID: 37830395
Thank you ThHiTechCoach, I will try it out tomorrow.

Jeff, thanks for the link
0
 
LVL 1

Assisted Solution

by:Alaska Cowboy
Alaska Cowboy earned 0 total points
ID: 37830835
TheHiTechCoach - the label still displays if there are no records in the subreport, see "Environment - Refuse Manager - Comanichi" (and others below that).
- I had also tried that to no avail

I also tried your first suggestion to no avail (see attached)
-->Me.Candidate_Other.Visible = Me.rptPositionsByCandidate.Report.HasData

Jeff, thanks, but that link seemed to be about handling a report with no data, so I didn't see the connection.
Candidates-EE.accdb
0
 
LVL 74

Assisted Solution

by:Jeffrey Coachman
Jeffrey Coachman earned 150 total points
ID: 37830954
<I'm trying to hide the subreport label if there is no data in the subreport.>
Actually it's a textbox...

<the label still displays if there are no records in the subreport, see "Environment - Refuse Manager - Comanichi" (and others below that).>
Am I missing something?
For ""Environment - Refuse Manager - Comanichi""
...I *do not* see the textbox...
screen
0
 
LVL 1

Author Comment

by:Alaska Cowboy
ID: 37830971
>> >><I'm trying to hide the subreport label if there is no data in the subreport.>
>>Actually it's a textbox...
- yes, good point, that was on purpose.

but the d.b. I just posted shows this:

report_pic
Thanks a lot, will pick it up tomorrow :-)
0
 
LVL 1

Accepted Solution

by:
Alaska Cowboy earned 0 total points
ID: 37831138
I ended up solving this by adding a field to the sub-report with this expression:

=IIf(IsNull([Position_Descr_Long]),Null,"Other Positions:")

So if there is no data in the subreport nothing displays.

This shows on the report like this:

Position: Controller
    Candidate: John Doe
         Other Positions:  Marketing Director
                                     COO

not the prettiest and elegant, but it works. I do appreciate the help as it's helping me get over the initial learning curve.
0
 
LVL 1

Author Closing Comment

by:Alaska Cowboy
ID: 37850279
I couldn't get the suggestion to work, but I've seen the same thing in other questions.
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question