View Full Version : Suppress subform conditionally?


Paul Wagner
12-29-2004, 05:53 PM
I have a subform on a report. However, it is appearing in a Group footer. How can I control the printing of it (and/or its contents) so that it prints ONLY under 1 group?

TIA

Pat Hartman
12-29-2004, 06:09 PM
If it doesn't apply to each group, it shouldn't be in the group footer. Move it to the Report Footer to print it only once for the report.

Paul Wagner
12-29-2004, 06:49 PM
Thanks Robert. On the surface I would agree with you. However, there is another occurrence of records in a group just after the reporting of this subform:
Group 1
Group Break A
row a: amt1 amt2 amt3
row b: amt1 amt2 amt3
Group Break B
row c: amt1 amt2 amt3
row d: amt1 amt2 amt3

Sum of Group 1 (my perceived notion of a single subform here)
Group A total total total
Group B total total total

Group 2
Group Break C
row e: amt1 amt2 amt3
row f: amt1 amt2 amt3

Paul Wagner
12-29-2004, 06:50 PM
Pat: Sorry, I called you Robert (note to self: read...the...message...first)

Pat Hartman
12-29-2004, 07:35 PM
:) :)
Are you trying to make a recap? So in the Group 1 break, you have totals for the GroupA and GroupB? Why would you not want the GroupC total in the Group2 break?

You may be able to control the subreport by changing its visible property depending on some value. Put the code in the onFormat event of the Group footer. Don't forget to make the can grow and can shrink properties = Yes.

Paul Wagner
12-29-2004, 08:35 PM
OK, I suppose I could have another "recap" in last group, following the format of the first. However, I'm not sure how to do that without a subreport. I've created an artificial sort/group field to collect GroupA and B into Group 1, but I really don't know how to summarize those as displayed above.

The Group C group is a whole different reporting group for the user and they want to see it below the first.

I'll try the Onformat event. What kind of value test can I make?

Thanks!!!

Pat Hartman
12-30-2004, 01:44 PM
Test to see if the current group is Group1.

If Me.GroupName = 1 Then
Me.MysubReport.Visible = True
Else
Me.MySubReport.Visible = False
End If

Paul Wagner
12-30-2004, 03:54 PM
Very cool and clean Pat. Thank you ever so much. And thank you for your generosity of your time. That too is appreciated!!

Paul

Paul Wagner
12-31-2004, 05:34 AM
Yipes. I guess I got too excited too fast.

I thought Groupname was a natural construct and it became obvious you gave me a generic example.

What is Groupname? Does it have anything to do with the code?

Private Sub GroupFooter5_Format(Cancel As Integer, FormatCount As Integer)

Pat Hartman
12-31-2004, 01:17 PM
GroupName is the name of whatever field you are grouping on. Its value in your example is "Group 1" and "Group 2" but I don't know what its name is.

Paul Wagner
01-03-2005, 08:45 AM
Resolved. Thank you Pat. Yes, I was able to use the group name.

Paul