Screen vs Print differences

  • Thread starter Thread starter Y. Gauthier
  • Start date Start date
Y

Y. Gauthier

When I generate a report, it is first previewed on the screen, then
the user decides to print or not.

But a value (tAllDkt) on one control (Me.totLen) is wrong on screen
but correct on paper.

Here are the sections where the variable is used:

* in (General)

Dim tAllDkt As Double

* in Private Sub Report_Activate()

tAllDkt = 0

* in Private Sub Report_Open(...)

tAllDkt = 0

* in Private Sub Detail_Print(...)

If Not noData Then

tAllDkt = tAllDkt + tDkt


* in Private Sub ReportFooter_Print(...)

Me.totLen = tAllDkt

* in Private Sub ReportHeader_Print(...)

tAllDkt = 0


What can be the cause of the difference?
 
Using the events of the sections to collect a total that spans pages is not
reliable in Access.

To get a total of field "tAllDkt" at the end of your report, place a text
box in the Report Footer section, and set its ControlSource to:
=Sum([tAllDkt])

If you need a progressive total, use a running sum, i.e. a text box with
Running Sum set to "Over All".
 
Thanks Allen for replying
To get a total of field "tAllDkt" at the end of your report, place a text
box in the Report Footer section, and set its ControlSource to:
=Sum([tAllDkt])

I've tried this, but a pop-up window
"Enter parameter value: tAllDkt" appears...

Even if I added in ReportFooter_Print:
Me.Test = tAllDkt

I tried the same in Detail_Print, still...

How this info can be entered automatically?
 
Okay, where does this control get its data from?
Is it in the source query?
If not, can you create a calculated field in the source query so it can be
summed?

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Y. Gauthier said:
Thanks Allen for replying
To get a total of field "tAllDkt" at the end of your report, place a text
box in the Report Footer section, and set its ControlSource to:
=Sum([tAllDkt])

I've tried this, but a pop-up window
"Enter parameter value: tAllDkt" appears...

Even if I added in ReportFooter_Print:
Me.Test = tAllDkt

I tried the same in Detail_Print, still...

How this info can be entered automatically?
 
Hi Allen,

I reach what seems to be a good result:

In Detail, the control source is
=[a]++[c]
(no running sum)

In report footer, the control source is
=Sum([a]++[c])
Running Sum "Over All"

So I get on each line the total of a+b+c of that line

And on the last line the total of all a, b, and c`s of the report

Is the result reliable?

Okay, where does this control get its data from?
Is it in the source query?

In the Report_Open event, I assign an SQL command to Me.RecordSource
If not, can you create a calculated field in the source query so it can be
summed?

I think I did...

Thanks Allen,

Yves
 
Hi Allen,

I reach what seems to be a good result:

In Detail, the control source is
=[a]++[c]
(no running sum)

In report footer, the control source is
=Sum([a]++[c])
Running Sum "Over All"

So I get on each line the total of a+b+c of that line

And on the last line the total of all a, b, and c`s of the report

Is the result reliable?

Okay, where does this control get its data from?
Is it in the source query?

In the Report_Open event, I assign an SQL command to Me.RecordSource
If not, can you create a calculated field in the source query so it can be
summed?

I think I did...

Thanks Allen,

Yves
 
A Control Source of:
=Sum([a]++[c])
in a text box in the Report Footer section will fine.
(You don't need the Running Sum property set for this control.)
 
Back
Top