Report Group Format Event Firing twice?

  • Thread starter Thread starter Henry Smith
  • Start date Start date
H

Henry Smith

I have a report, based on a query, with a detail section and group sections.
In the Group Footer Format event I have a Select Case process to perform
addition and subtraction and then fill a text box with the results.
Depending on the value of the group text box (string value) (there are 5 in
all) determines what addition or subtraction is performed, if any. This
whole process works well except for the second Select Case item (the second
string value of the five tested for). Inside each Select Case item there is
similar code. Text boxes are either visible = true or visible = false
depending on weather I need to have that text box displayed on the report
with the arithmetic results.
The rules, as I understand them, is that the Group Format event should only
fire once. In my case the second Select Case item fires twice. Of course
this means my arithmetic results are wrong for that item. Code inside the
second Select Case item is similar to the other Select Case items.
Any suggestions as to what is causing this problem? How can I troubleshoot
this problem?
Any help will be greatly appreciated.
Cheers,
Henry
 
Hi

Report sections can be formatted more than once, so you'll
need to put something like

If Me.FormatCount = 1 Then
...do your stuff
end if

in the Group Footer format event. This will ensure your
calculation is performed only once.

hth

Chris
 
Chris,
Problem solved.
Thank you for your suggestion. Unfortunately, in my case your solution will
not work because I am trying to perform several mathematical calculations
and display the results in a defined text box. Using the if...then...else
process will prevent the more than once firing of the event from going
through the calculations it prevents the results from being displayed.
Basically, you are correct that we can't predict how many times the format
event will fire. So the solution is that when one is using an event to
perform calculations with subsequent displays the event to use is the PRINT
event. The print event may even occur more than once, but it will not
effect the formatting and therefore not effect the calculations since the
PRINT event happens after the format event. Essentially, if you perform the
calculations inside the print event, even if the print event happens more
than once, your calculations are preserved and printed as requested.
 
Back
Top