A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Setting Up & Running Reports
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Report Being Rerun in Print Preview and Print



 
 
Thread Tools Display Modes
  #1  
Old September 13th, 2007, 02:12 PM posted to microsoft.public.access.reports
2005sporty
external usenet poster
 
Posts: 5
Default Report Being Rerun in Print Preview and Print

Hello,

I have a report where I am using code to generate the data in the report.
The data that is being rerun in the detail section and is creating inaccurate
results.
The issue I'm having is that data is being rerun. What is in the preview
screen is not what is printed (we have all our reports set to preview as the
users don't always print them after they're generated). I found some info
regarding this

"Access fires the events again when the report prints after preview, so you
need to reset your variables in the Report Header's Format event.
Report_Open does not fire again."

I am not that familiar with code and am not sure of the code that I need to
do this.
I have this in the Header now

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

End Sub

Any info would be greatly appreciated
  #2  
Old September 13th, 2007, 04:04 PM posted to microsoft.public.access.reports
Marshall Barton
external usenet poster
 
Posts: 5,361
Default Report Being Rerun in Print Preview and Print

2005sporty wrote:

Hello,

I have a report where I am using code to generate the data in the report.
The data that is being rerun in the detail section and is creating inaccurate
results.
The issue I'm having is that data is being rerun. What is in the preview
screen is not what is printed (we have all our reports set to preview as the
users don't always print them after they're generated). I found some info
regarding this

"Access fires the events again when the report prints after preview, so you
need to reset your variables in the Report Header's Format event.
Report_Open does not fire again."

I am not that familiar with code and am not sure of the code that I need to
do this.
I have this in the Header now

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

End Sub



The info you found is only sufficient in very simplistic
reports. In general, you can not use code in a report's
event procedures to calculate values that depend on anything
beyond the fields in a single detail record. The common
case where your problem is seen when you try to add the
values of a field using code like:

Dim total As Long
Sub Detail_Format(...
total = total + somefield
End sub

That kind of approach will fail to calculate a correct total
because reports fire event procedures as many times and in
whatever order is needed to lay out all the sections
according to your various property settings.

Generally, the aggregate functions should to calculate multi
record totals. Or maybe the report requires a more
sophisticated record source query that takes care of the
calulations.

--
Marsh
MVP [MS Access]
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 03:25 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.