Sum Problem

A

A Hopper

I have the code at the end of this message in the On Print
event of a report. The variables have been declared as
Single. The code is working as I want. The report detail
is what I want except for three text
boxes,"JobGood", "JobSpoils" and "JobSpoilage", in a
footer I added (not page footer).
I want
"JobGood" to be the sum of Me.SkidGood
"JobSpoils" to be the sum of Me.SkidSpoil
(Me.SkidGood and Me.SkidSpoil are unbound text boxes whose
values are determined by the code below at the end of this
message.)

"JobSpoilage" is to be Me.JobSpoils / Me.JobGood * 100

If Me.PackGood < 1 Then "SkidGood" and "SkidSpoil" are 0.

I have tried Setting the source of "JobGood"
to "SkidGood", "JobSpoil" to "SkidSpoil" and then setting
the Running Sum to Over All but it will not work. I
believe I am having this problem because "SkidGood"
and "SkidSpoil" are determined by the On Print event. Even
though I get all the skids listed and the values correct
in "SkidGood" and "SkidSpoil", the report will not sum
them for "JobGood" and "JobSpoil". I get 0 value.

The product is produced in Skids. Each skid is assigned a
number. The skids may be packaged in any order and if the
product is bad a skid may never be packaged. I want to use
information only from Skids that have been packaged and so
Me.PackGood is used as the criteria for "SkidGood"
and "SpoilGood"

Thanks for your help

Allan


Code below:

OnePositionPackaged = (Nz(DSum("(Nz
([GoodOnePack]))", "OneGPackData", "[JobNumber]=" &
Me.JobNumber & "And [SkidNumber]=" & Me.SkidNumber)))

Me.PackGood = Nz(OnePositionPackaged)

OnePositionSkidScrewsPackaged = Nz(OnePositionPackaged) *
Nz(PackUnitScrews)

Me.SkidGood = Nz(OnePositionSkidScrewsPackaged)

OnePSkidCalculatedSpoil = Nz(SkidImpressionScrews) - Nz
(OnePositionSkidScrewsPackaged)

If Nz(Me.PackGood) >= 1 Then
Me.SkidSpoil = Nz(OnePSkidCalculatedSpoil)
SpoilageForSkid = (Nz(OnePSkidCalculatedSpoil) / Nz
(OnePositionSkidScrewsPackaged)) * 100
Me.SkidSpoilage = Nz(SpoilageForSkid)
End If

If Nz(Me.PackGood) < 1 Then
Me.SkidSpoil = Null
SpoilageForSkid = 0
Me.SkidSpoilage = Null
End If
 

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