Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Access 2010 report - detail format event over page break

Posted on 2013-01-25
5
Medium Priority
?
1,328 Views
Last Modified: 2013-01-26
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
Comment
Question by:MonkeyPie
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 

Author Comment

by:MonkeyPie
ID: 38821533
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
 
LVL 40

Expert Comment

by:als315
ID: 38821569
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
 
LVL 85

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 2000 total points
ID: 38821900
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
 
LVL 58
ID: 38822130
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
 

Author Closing Comment

by:MonkeyPie
ID: 38823116
Great. Problem solved.  Thanks.
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question