Report Being Rerun in Print Preview and Print

G

Guest

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
 
M

Marshall Barton

2005sporty said:
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.
 

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