View Full Version : Subreport On No Data event problem
lmcc007 05-30-2010, 04:00 PM I have a report with a subreport. Sometimes the subreport has data and sometimes it does not.
If the subreport has no data, I want the lblAdditionalAddresses label to not be visible. In the subreport On No Data even I entered the following code:
Reports![rptCompanyProfile]![lblAdditionalAddresses].Visible = False
It is not working.
How can I get this to work?
Thanks.
HiTechCoach 05-30-2010, 09:56 PM I have a report with a subreport. Sometimes the subreport has data and sometimes it does not.
If the subreport has no data, I want the lblAdditionalAddresses label to not be visible. In the subreport On No Data even I entered the following code:
Reports![rptCompanyProfile]![lblAdditionalAddresses].Visible = False
It is not working.
How can I get this to work?
Thanks.
Sure.
See:
Previous Thread Here (http://www.utteraccess.com/forum/subreport-display-t1838020.html&hl=Hasdata)
lmcc007 05-30-2010, 10:39 PM Okay I am not following the below:
You can use the .HasData property of the sub report in the On Format event like this:
Me.lblMyLabel.Visible = Not Me.MySubReport.HasData
When I open the subreport I don't see an On Format event. Then opened the main report and don't see it either. I'm missing something steps or something here.
HiTechCoach 05-30-2010, 10:56 PM Okay I am not following the below:
You can use the .HasData property of the sub report in the On Format event like this:
Me.lblMyLabel.Visible = Not Me.MySubReport.HasData
When I open the subreport I don't see an On Format event. Then opened the main report and don't see it either. I'm missing something steps or something here.
A main report object does not have a On Format event. Sections of the report have an On Format event. For example the Report Header section, the detail section, etc. is where you will find the On Format events.
You will place the code in the Parent (main) report in the On Format event of the section that has the sub report. I assume this is also the same section with the label.
lmcc007 05-30-2010, 11:08 PM A main report object does not have a On Format event. Sections of the report have an On Format event. For example the Report Header section, the detail section, etc. is where you will find the On Format events.
You will place the code in the Parent (main) report in the On Format event of the section that has the sub report. I assume this is also the same section with the label.
Thanks I would have never found it--learn something new.
Yes, the label and subreport is in the Detail Section.
I posted the code but gets an error:
Compile error:
Method or data member not found
lmcc007 05-30-2010, 11:24 PM Hi HiTechCoach,
To get rid of the error message I had to enter it like:
Me.lblAdditionalAddresses.Visible = Not Me.rsubAdditionalAddresses.Report.HasData
But it did nothing.
Then I tried:
If Me.rsubAdditionalAddresses.Report.HasData Then
Me.lblAdditionalAddresses.Visible = True
Else
Me.lblAdditionalAddresses.Visible = False
Me.Line122.Visible = False
End If
It works, but leave too many spaces--doesn't shrink.
HiTechCoach 05-30-2010, 11:24 PM What code did you use?
In my example:
Me.lblMyLabel.Visible = Not Me.MySubReport.HasData
Did you substitute lblMyLabel with your label name?
Did you substitute MySubReport with your subreport's name?
It should look something like:
Me.lblAdditionalAddresses.Visible = Not Me.Your_SubReport_Name_Goes_Here.HasData
I do not know the name of your sub report. You will have to substitute it in the palce of Your_SubReport_Name_Goes_Here
lmcc007 05-30-2010, 11:26 PM Here is the code I used:
Me.lblAdditionalAddresses.Visible = Not Me.rsubAdditionalAddresses.Report.HasData
HiTechCoach 05-30-2010, 11:31 PM To get the extra space to "shrink" you will need to set the section's Can Shrink Property to Yes. You may also need to set the Sub Report Control's Can Shrink Property to Yes.
HiTechCoach 05-30-2010, 11:33 PM Here is the code I used:
Me.lblAdditionalAddresses.Visible = Not Me.rsubAdditionalAddresses.Report.HasData
Try this:
Me.lblAdditionalAddresses.Visible = Me.rsubAdditionalAddresses.Report.HasData
Me.Line122.Visible = Me.rsubAdditionalAddresses.Report.HasData
lmcc007 05-30-2010, 11:49 PM To get the extra space to "shrink" you will need to set the section's Can Shrink Property to Yes. You may also need to set the Sub Report Control's Can Shrink Property to Yes.
Thanks!
I set them all but it is still not shrinking. I'm tired--I will try it again tomorrow.
lmcc007 05-30-2010, 11:52 PM Try this:
Me.lblAdditionalAddresses.Visible = Me.rsubAdditionalAddresses.Report.HasData
Me.Line122.Visible = Me.rsubAdditionalAddresses.Report.HasData
Thanks!
This code works, but still not shrinking.
|