How to print / not print a subreport (1 Viewer)

Gkirkup

Registered User.
Local time
Today, 03:32
Joined
Mar 6, 2007
Messages
628
I have a report that is used to print a packing list. For one class of customer I need to also print a subreport with more information, on the same page. I don't want to duplicate the report for this one change, but am looking for a way to print or not print the subreport, perhaps in code?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 03:32
Joined
Oct 29, 2018
Messages
21,467
Hi. Try a no code solution first. Add the subreport but make it really small in height and set the Can Grow property to Yes. This is assuming only one customer has data in the subreport.
 

Gkirkup

Registered User.
Local time
Today, 03:32
Joined
Mar 6, 2007
Messages
628
Thanks dbguy. There are headings etc on the subreport and I don't think I could make it small enough to be invisible to all other customers. I am really looking for code to print or not print the subreport, based on customer type.

Robert
 

theDBguy

I’m here to help
Staff member
Local time
Today, 03:32
Joined
Oct 29, 2018
Messages
21,467
Thanks dbguy. There are headings etc on the subreport and I don't think I could make it small enough to be invisible to all other customers. I am really looking for code to print or not print the subreport, based on customer type.

Robert
Hi Robert. I don't see how you can't make it height=0 even with headers; but if you really want to use code, then in the Open event of the Report, you could try something like:
Code:
If Me.CustomerType="something" Then
    Me.SubreportName.Visible=True
Else
    Me.SubreportName.Visible=False
End If
 

June7

AWF VIP
Local time
Today, 02:32
Joined
Mar 9, 2014
Messages
5,468
The subreport container control height would be 0" and with its CanGrow property, it grows when there is data in the report. But apparently only when it is in Detail section.
 
Last edited:

June7

AWF VIP
Local time
Today, 02:32
Joined
Mar 9, 2014
Messages
5,468
Don't think Open event will work. Try Format event of section subreport container control is in. Then would have to set height of the container to 0 otherwise there will be big white space where the container resides. Format event executes only for PrintPreview or direct to printer. Did you see post 5?
 

isladogs

MVP / VIP
Local time
Today, 11:32
Joined
Jan 14, 2017
Messages
18,211
You could also use OpenArgs to control the visibility of the subreport.
Where the OpenArgs value ="Customer", the subreport is shown, otherwise hidden
 

Gkirkup

Registered User.
Local time
Today, 03:32
Joined
Mar 6, 2007
Messages
628
DBGuy: How do I set the height of the new subreport to zero? I found the 'can grow' in the detail section, but when I try to set the height there to 0.0" it returns to the number that was previously set. I can make the new subform invisible but it still takes room on the page and sometimes forces a blank page.
Thank you. Robert
 

June7

AWF VIP
Local time
Today, 02:32
Joined
Mar 9, 2014
Messages
5,468
Did you see posts 5 and 7? Set height of the subreport container control. Not the report object held by the container.
 
Last edited:

Users who are viewing this thread

Top Bottom