[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1341
  • Last Modified:

Access 2010 report - detail format event over page break

I have an access 2010 report.  On the detail format event I collect some totals.  The totals weren't quite right so I added some debug.print statements to track what was happening.  It seems that when the detail section goes over a page the detail line at the top of the second page is formatted twice.  ie. the detail-format event is triggered twice so that amount is added to the total twice.

The code in the detail_Format event is something like: TotalAmt - TotalAmt + ThisAmt

So, TotalAmt is always equal to what it should be plus the 2nd page first item added in again.  If I change where the page break happens the total changes accordingly.

Is this a bug?  Any ideas how to fix this?  I know I can use sum([field]) to total the detail section automatically but I want to do other things with the totals I collect.
0
MonkeyPie
Asked:
MonkeyPie
1 Solution
 
MonkeyPieAuthor Commented:
Further to my question above....
Perhaps the detail_Format event is not the right place to collect the totals?  But report OnCurrent event doesn't work. So is there another event I can use to step through each record in the source?
0
 
als315Commented:
Can you upload sample DB and show expected result? You can save current value of some unique field and do not add value to total if this value was not changed from previous event
0
 
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
The format events occur each time Access formats, and Access can perform formatting on the same section more than one.

Access does maintain a 'count' of the formats -  you could refer to that, and if the count > 1 for your section, you could not run your code. See this for a bit more detail:

http://msdn.microsoft.com/en-us/library/office/aa195897%28v=office.11%29.aspx

So, in the Format event that you're using, you could do this:

If FormatCount = 1 Then
  '/ do your calculations
End If
0
 
Jim Dettman (Microsoft MVP/ EE MVE)PresidentCommented:
As LSM has said, this is not unexpected and often the report engine will retreat up the page to refomat it.

Besides the Format event, the print even may occur multiple times as well.

The simplest then is to check the FormatCount as LSM suggested.   An alternative is to use the OnRetreat event to subtract the total back out.

Jim.
0
 
MonkeyPieAuthor Commented:
Great. Problem solved.  Thanks.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now