Is it possible to make a Sub Report Not Visible based on the numeric content of a field on the Main Report.
So, if [txtNeeded] > 0, subReport. Visible = False
Thanks in advance for any help,
Cheers
Is it possible to make a Sub Report Not Visible based on the numeric content of a field on the Main Report.
So, if [txtNeeded] > 0, subReport. Visible = False
Thanks in advance for any help,
Cheers
Cheers,
Andy

This month, every Windows Secrets subscriber can download a one-chapter excerpt of Windows 7: The Missing Manual.Windows 7: The Missing Manual provides valuable information to help you overcome these difficulties in learning a new operating system. Subscribe today to download your free excerpt.
Yes the subreport control has a visible property.
Use the following to make it visible or not. Be sure to use the name of the subreport control. It can be different from the subreport.
Me.SubreportControlName.Visisble = Me.[txtNeeded] <= 0
Francois
http://www.wopr.com/S/Belgium.gif
Francois,
Thanks kindly or merci bien, worked beautifully.
Cheers,
Cheers,
Andy
Francois,
As I mentioned above, your solution worked perfectly based on:
Private Sub GroupFooter0_Print(Cancel As Integer, PrintCount As Integer)
Me.subFuji.Visible = [txtNeeded] > 0
End Sub
Now just to add another layer of complexity to my life I’d like to ‘not print’ the whole of the detail line that contains the [txtNeeded] field based on my code sample below.
I’ve done the following which got rid of the specific field, txtProdNo. Being too lazy to repeat the same code for the other twelve fields, I thought there might be a way to hide the whole line in one swell foop.
Private Sub GroupHeader1_Print(Cancel As Integer, PrintCount As Integer)
Me.txtProdNo.Visible = [txtNeeded] > 0 and [S01] > 0
End Sub
Thanks in advance for looking at this and bearing with my laziness,
Cheers,
Cheers,
Andy
Perhaps not suprisingly, the group footer also has a Visible property (as you'd have seen if you had taken a second to look)
Private Sub GroupFooter0_Print(Cancel As Integer, PrintCount As Integer)
Me.GroupFooter0.Visible = [txtNeeded] > 0
End Sub
or you can cancel the footer:
Private Sub GroupFooter0_Print(Cancel As Integer, PrintCount As Integer)
Cancel = [txtNeeded] <= 0
End Sub
Hans,
Sorry for the delay in getting back to you. Also, my apologies if I’ve misconstrued something.
Anyway here is the code that has come closest to what I want to do:
Private Sub GroupHeader1_Format(Cancel As Integer, FormatCount As Integer)
Me.GroupHeader1.Visible = [txtNeeded] > 0 And [S01] > 0
End Sub
Private Sub GroupFooter0_Print(Cancel As Integer, PrintCount As Integer)
Me.subFuji.Visible = [txtNeeded] > 0 And [S01] > 0
End Sub
It however does not compress, if you wish, the detail line in the GroupHeader1 when there is no data, so that I’m left with obvious gaps where there is null data.
Hopefully, there is a workaround without my having to apply too much egg to my face,
Cheers,
Cheers,
Andy
If you want to hide a section if there are no data, you will have to check whether there are data or not. The current code checks whether some values are positive.
Hans,
There are data, but they do not meet the requirements, so I'm trying to hide them.
Cheers,
Cheers,
Andy
I'm getting very confused by all these contradictory statements. Could you post a stripped down copy of your database? See <post#=401925>post 401925</post#> for instructions.
Hans,
It was easier than I thought.
Open rpt 01 CN - FujiAssignments – 04
The 2nd line down is the culprit.
Hope this helps,
Cheers,
Cheers,
Andy
1) You hadn't set the Can Shrink property of the subform control in the main report to Yes.
2) The Detail_Format code in the subreport wasn't "connected" to the event - the corresponding box in the Event tab of the Properties window was empty. So the code wasn't executed.
See attached version.
Hans,
Thanks for checking this out. The good news is that the "blank line" no longer shows, but the subline for CAN0800033 which was displayed in the original example, has gone missing. Unless something happened in the code coming back to me.
Cheers,
Cheers,
Andy
Use the On Format event of the group footer instead of the On Print event to show/hide the subform.
Hans,
Sorry for the late reply, but I was forced to go to an Italian wine tasting this evening. Such pressure.
But, as always, your final solution is bang on.
I really appreciate your patience,
Cheers,
Cheers,
Andy
> go to an Italian wine tasting
Life is hard... <img src=/S/grin.gif border=0 alt=grin width=15 height=15>