Add GroupFooter to existing grouplevel in code?

D

Dave Bolt

I have lots of reports which need to be updated by adding a GroupFooter.
I have this snippet of code which does the job, almost.

Dim varGroupLevel As Variant
For Each accobj In CurrentProject.AllReports
strDoc = accobj.Name
DoCmd.OpenReport strDoc, acViewDesign 'Currently working in Access
2000
With Reports(strDoc)
If Not .GroupLevel(0).GroupFooter Then
varGroupLevel = CreateGroupLevel(strDoc, "PrintOrder",
False, True)
End If
End With

So the problem is that when I view the grouping information in a report that
has been updated with this code, I see two entries. The original one without
the footer, and the new one with the footer.
I only see one detail and one footer in design view.
How do I get rid of the original entry in code?
Do I need to?
Am I doing this all wrong?
Thanks
Dave
 
M

Marshall Barton

Dave said:
I have lots of reports which need to be updated by adding a GroupFooter.
I have this snippet of code which does the job, almost.

Dim varGroupLevel As Variant
For Each accobj In CurrentProject.AllReports
strDoc = accobj.Name
DoCmd.OpenReport strDoc, acViewDesign 'Currently working in Access
2000
With Reports(strDoc)
If Not .GroupLevel(0).GroupFooter Then
varGroupLevel = CreateGroupLevel(strDoc, "PrintOrder",
False, True)
End If
End With

So the problem is that when I view the grouping information in a report that
has been updated with this code, I see two entries. The original one without
the footer, and the new one with the footer.
I only see one detail and one footer in design view.
How do I get rid of the original entry in code?
Do I need to?
Am I doing this all wrong?


You are trapped in a twisty maze of catch 22 situations.

It would be nice if you could just set the existing group
level's GroupFooter property to True to create the footer
section, BUT the GroupFooter property is ReadOnly.

You can only specify the GroupFooter in the CreateGroupLevel
function. Hovever, you need to delete the existing group
level 0 before you can recreate it, BUT there is no way to
delete a group level.

I think you are doomed to manually modifying existing group
levels to add the footer.

If group level 0 doesn't exist, then your If statement above
will trigger trappable error2464 so you can create it with
your above code.
 
D

Dave Bolt

Thanks Marsh.
I suspected as much.
Do you know if the solution is any better in Access 2003?
Regards
Dave
 
M

Marshall Barton

It's been this way in every version from A2 through A03. I
haven't check A07 yet, but I doubt it will be any different
because GroupLevel is not a normal object in the overall
object model scheme of things.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top