report values change when printing

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello
I have a report which displays perfectly when in preview mode. However the
values in two of the textboxes on the report seem to double up when I try to
print it. This happens whether I initiate printing programmatically or open
in preview mode and print from the file menu. Does anyone have any idea why
this is happening? The code is as follows:

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

'allocate time to Wider Opps or Normal
Select Case Me!Text148

Case Is = 2 'Wider Opps

Me![WopHrs] = Nz(Me![WopHrs]) + Me![Text151]

Me![WopMins] = Nz(Me![WopMins]) + Me![Text152]

Case Else 'Normal

Me![NormalHrs] = Nz(Me![NormalHrs]) + Me![Text151]

Me![NormalMins] = Nz(Me![NormalMins]) + Me![Text152]

End Select

End Sub

The boxes WopHrs, WopMins, NormalHrs and NormalMins are in a group footer
while Text151 and Text152 are in the detail section.

Any help would be gratefully received.
 
Aggregating in code rarely is reliable in report events. You should normally
not have to write any code sum values in a report. For instance, if you have
[WOP_NORM] field with either 1 or 2 stored in the field you can sum another
field where [WOP_NORM] = 1. Use an expression like:

=Sum( Abs([WOP_NORM]=1) * [WopHrs])

If this doesn't meet your needs, come on back.
 
Thanks for your reply Duane

I have tried

Me![WopHrs] = Sum(Abs([Me!Text148] = 2) * Me![WopHrs])

where Text148 equates to your WOP_NORM field, but the code halts with a
'Sub or Function not defined' error and the last part of the statement
greyed out.

What have I done wrong?

Wes.

Duane Hookom said:
Aggregating in code rarely is reliable in report events. You should normally
not have to write any code sum values in a report. For instance, if you have
[WOP_NORM] field with either 1 or 2 stored in the field you can sum another
field where [WOP_NORM] = 1. Use an expression like:

=Sum( Abs([WOP_NORM]=1) * [WopHrs])

If this doesn't meet your needs, come on back.

--
Duane Hookom
MS Access MVP


Wez.k said:
Hello
I have a report which displays perfectly when in preview mode. However
the
values in two of the textboxes on the report seem to double up when I try
to
print it. This happens whether I initiate printing programmatically or
open
in preview mode and print from the file menu. Does anyone have any idea
why
this is happening? The code is as follows:

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

'allocate time to Wider Opps or Normal
Select Case Me!Text148

Case Is = 2 'Wider Opps

Me![WopHrs] = Nz(Me![WopHrs]) + Me![Text151]

Me![WopMins] = Nz(Me![WopMins]) + Me![Text152]

Case Else 'Normal

Me![NormalHrs] = Nz(Me![NormalHrs]) + Me![Text151]

Me![NormalMins] = Nz(Me![NormalMins]) + Me![Text152]

End Select

End Sub

The boxes WopHrs, WopMins, NormalHrs and NormalMins are in a group footer
while Text151 and Text152 are in the detail section.

Any help would be gratefully received.
 
Sorry Duane, the light dawned after I made the previous post. I'm meant to
put the statement into the Data property of the box itself right?

I'll try it now.

Wes.
 
OK Duane. Now I have the following in the WopsHrs box

=Sum(Abs([Text148]=2)*[Hours])

and similar in the others. Text148 equates to your WOP_NORM field and Hours
and Mins are the values of hours and minutes which need to be agregated to
WopHrs and NormalHrs etc.
When I try to open the report I get requests for Parameter values for
Text148, Hours and Mins. All three of these derive their values from the
reports underlying query so I dont understand why their values are not being
picked up.

Wes.

Duane Hookom said:
Aggregating in code rarely is reliable in report events. You should normally
not have to write any code sum values in a report. For instance, if you have
[WOP_NORM] field with either 1 or 2 stored in the field you can sum another
field where [WOP_NORM] = 1. Use an expression like:

=Sum( Abs([WOP_NORM]=1) * [WopHrs])

If this doesn't meet your needs, come on back.

--
Duane Hookom
MS Access MVP


Wez.k said:
Hello
I have a report which displays perfectly when in preview mode. However
the
values in two of the textboxes on the report seem to double up when I try
to
print it. This happens whether I initiate printing programmatically or
open
in preview mode and print from the file menu. Does anyone have any idea
why
this is happening? The code is as follows:

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

'allocate time to Wider Opps or Normal
Select Case Me!Text148

Case Is = 2 'Wider Opps

Me![WopHrs] = Nz(Me![WopHrs]) + Me![Text151]

Me![WopMins] = Nz(Me![WopMins]) + Me![Text152]

Case Else 'Normal

Me![NormalHrs] = Nz(Me![NormalHrs]) + Me![Text151]

Me![NormalMins] = Nz(Me![NormalMins]) + Me![Text152]

End Select

End Sub

The boxes WopHrs, WopMins, NormalHrs and NormalMins are in a group footer
while Text151 and Text152 are in the detail section.

Any help would be gratefully received.
 
Do you have a field in your report's record source named "Text148"? You need
to sum fields/expressions from your reports record source.

--
Duane Hookom
MS Access MVP

Wez.k said:
OK Duane. Now I have the following in the WopsHrs box

=Sum(Abs([Text148]=2)*[Hours])

and similar in the others. Text148 equates to your WOP_NORM field and
Hours
and Mins are the values of hours and minutes which need to be agregated to
WopHrs and NormalHrs etc.
When I try to open the report I get requests for Parameter values for
Text148, Hours and Mins. All three of these derive their values from the
reports underlying query so I dont understand why their values are not
being
picked up.

Wes.

Duane Hookom said:
Aggregating in code rarely is reliable in report events. You should
normally
not have to write any code sum values in a report. For instance, if you
have
[WOP_NORM] field with either 1 or 2 stored in the field you can sum
another
field where [WOP_NORM] = 1. Use an expression like:

=Sum( Abs([WOP_NORM]=1) * [WopHrs])

If this doesn't meet your needs, come on back.

--
Duane Hookom
MS Access MVP


Wez.k said:
Hello
I have a report which displays perfectly when in preview mode. However
the
values in two of the textboxes on the report seem to double up when I
try
to
print it. This happens whether I initiate printing programmatically or
open
in preview mode and print from the file menu. Does anyone have any
idea
why
this is happening? The code is as follows:

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

'allocate time to Wider Opps or Normal
Select Case Me!Text148

Case Is = 2 'Wider Opps

Me![WopHrs] = Nz(Me![WopHrs]) + Me![Text151]

Me![WopMins] = Nz(Me![WopMins]) + Me![Text152]

Case Else 'Normal

Me![NormalHrs] = Nz(Me![NormalHrs]) + Me![Text151]

Me![NormalMins] = Nz(Me![NormalMins]) + Me![Text152]

End Select

End Sub

The boxes WopHrs, WopMins, NormalHrs and NormalMins are in a group
footer
while Text151 and Text152 are in the detail section.

Any help would be gratefully received.
 
Thanks Duane, problem solved!

Wes.

Duane Hookom said:
Do you have a field in your report's record source named "Text148"? You need
to sum fields/expressions from your reports record source.

--
Duane Hookom
MS Access MVP

Wez.k said:
OK Duane. Now I have the following in the WopsHrs box

=Sum(Abs([Text148]=2)*[Hours])

and similar in the others. Text148 equates to your WOP_NORM field and
Hours
and Mins are the values of hours and minutes which need to be agregated to
WopHrs and NormalHrs etc.
When I try to open the report I get requests for Parameter values for
Text148, Hours and Mins. All three of these derive their values from the
reports underlying query so I dont understand why their values are not
being
picked up.

Wes.

Duane Hookom said:
Aggregating in code rarely is reliable in report events. You should
normally
not have to write any code sum values in a report. For instance, if you
have
[WOP_NORM] field with either 1 or 2 stored in the field you can sum
another
field where [WOP_NORM] = 1. Use an expression like:

=Sum( Abs([WOP_NORM]=1) * [WopHrs])

If this doesn't meet your needs, come on back.

--
Duane Hookom
MS Access MVP


Hello
I have a report which displays perfectly when in preview mode. However
the
values in two of the textboxes on the report seem to double up when I
try
to
print it. This happens whether I initiate printing programmatically or
open
in preview mode and print from the file menu. Does anyone have any
idea
why
this is happening? The code is as follows:

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

'allocate time to Wider Opps or Normal
Select Case Me!Text148

Case Is = 2 'Wider Opps

Me![WopHrs] = Nz(Me![WopHrs]) + Me![Text151]

Me![WopMins] = Nz(Me![WopMins]) + Me![Text152]

Case Else 'Normal

Me![NormalHrs] = Nz(Me![NormalHrs]) + Me![Text151]

Me![NormalMins] = Nz(Me![NormalMins]) + Me![Text152]

End Select

End Sub

The boxes WopHrs, WopMins, NormalHrs and NormalMins are in a group
footer
while Text151 and Text152 are in the detail section.

Any help would be gratefully received.
 

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

Back
Top