473,397 Members | 1,949 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

How To hide a subreport?

16
How To hide a subreport?
I found how to know if the subreport has no data
(Me.subreportname.Report.HasData)
what I didn't find is how to make the sub report unvisibile if it has no data.
I tried:
If Not Me.subreportname.Report.HasData then
Me.subreportname.Report.Visible = False
End If
but it gave me an error
Sep 9 '07 #1
11 13756
lee123
556 512MB
hi there you could use this

Expand|Select|Wrap|Line Numbers
  1. if subreportname then
  2.    subreportname.visible = true
  3. else
  4.   subreportname.visible = false
  5. end if
lee123
Sep 9 '07 #2
MMcCarthy
14,534 Expert Mod 8TB
The first time you refer to the subreport you are referring to the report itself so you need the .Report

However, the second time you are referring to the subreport object so you don't use .Report

You also have to allow for the true event.

Expand|Select|Wrap|Line Numbers
  1. If  Me.subreportname.Report.HasData then
  2.     Me.subreportname.Visible = True
  3. Else
  4.     Me.subreportname.Visible = False
  5. End If
  6.  
Sep 9 '07 #3
DanielM
16
Thanks for your attention, the code was OK,
but still I have a problem, since my target was to save the space that the balnk subreport takes' and although the sub report was unvisible' still the page was with large blank space, in the palce that the subreports was supposed to sit.
Do you have any idea how to save the blank space?
Thanks.
Sep 10 '07 #4
FishVal
2,653 Expert 2GB
Thanks for your attention, the code was OK,
but still I have a problem, since my target was to save the space that the balnk subreport takes' and although the sub report was unvisible' still the page was with large blank space, in the palce that the subreports was supposed to sit.
Do you have any idea how to save the blank space?
Thanks.
Hi, Daniel.

Try the following.
  • Set subreport control .CanGrow = Yes
  • Reduce subreport control height to possible minimum
  • Handle subreport.Report "On No Data" event
    Expand|Select|Wrap|Line Numbers
    1. Private Sub Report_NoData(Cancel As Integer)
    2.     Cancel = True
    3. End Sub
    4.  
Sep 10 '07 #5
DanielM
16
Thanks a lot, but didn't work.
As much as I understood from searching google, the
"ON NO DATA" event, does not fire in the subreport.
Sep 10 '07 #6
FishVal
2,653 Expert 2GB
Thanks a lot, but didn't work.
As much as I understood from searching google, the
"ON NO DATA" event, does not fire in the subreport.
LOL. It is really so.

But it works without handling event.
At least in my test:
Several bound textboxes
Unbound label
Unbound checkbox

Did you shrink an empty report area having reduced subreport control height?
Sep 10 '07 #7
DanielM
16
Hi,
what did you mean "But it works without handling event." ?
Sep 10 '07 #8
FishVal
2,653 Expert 2GB
Hi,
what did you mean "But it works without handling event." ?
Screenshot in attachment.
Attached Images
File Type: jpg Shot.JPG (15.9 KB, 1506 views)
Sep 10 '07 #9
barry07
47
Daniel is correct that you don't need an event to hide the subreport. Just make the height of the subreport zero in design view and set CanGrow=Yes and CanShrink=Yes in the properties of the sub report.

However, you must also set CanGrow=Yes and CanShrink=Yes for the Report section which contains the subreport (|Detail, Report Footer or whatever)
Sep 10 '07 #10
DanielM
16
Thanks you all for your attention and time, It worked.
Sep 10 '07 #11
FishVal
2,653 Expert 2GB
You are welcome.

Kind regards,

Fish
Sep 10 '07 #12

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Steve Edwards | last post by:
I am trying to use an existing report as a subreport in another report. I have the subreport added to the main report, but the only thing that shows up where the subreport should be is the name of...
8
by: dixie | last post by:
I have a report with a subreport. The source object for this subreport varies according to the value of a field in a table. I am trying to programmatically set the object source for the subreport...
9
by: Downstreamer | last post by:
Design is as follows: A form for the user to input criteria to be used as the where part of the report's recordsource. This includes a multiselect list box as part of the criteria selection. ...
7
by: Ellen Manning | last post by:
I've got an A2K report showing students and their costs. Student info is in the main report and costs are in a subreport for each student. The user inputs the program desired then only those...
1
by: shaqattack1992-newsgroups | last post by:
I know this is kind of a weird question, but is there anyway to give a subreport control of a main report? I posted my situation earlier about having drawings print out after a group. I have a...
0
by: C | last post by:
Hi, I have a main Report which has a SubReport. This SubReport also has a SubReport. I set the data of my main Report and Subreport through code DataSet dsMainReport =...
11
by: Simon | last post by:
Dear reader, The syntax for the VBA code to change the RowSource of a Master Report is: Me.RowSource = "TableOrQueryName"
3
by: Simon | last post by:
Dear reader, The syntax for the VBA code to change the RecordSource of a Master Report is: Me.RecordSource = "TableOrQueryName"
3
by: tasawer | last post by:
Hi, When I print my report with subreport having no data, there is a big gap between the lines. How can I supress/hide subreport when it has no data.
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.