MS Access report problem with control/function refresh

Hi

I have an Access report with a sub report.  In the main report there is a text box (A) which takes a value from a control on the sub report.  The value in text box A is then used as one element of a grand total sum in another text box (B) on the main form.

Because the value of the control on the sub report could be null, as the sub form may not return any records, I use the function below as the Control Source for text box A to force a zero (this was suggested as the answer to one of my previous questions).

All this works fine if the report has a single record.  However where there is more than one record the Text box A value on the first record doesn't refresh for any subsequent record but stays the same on every page.  I have tried various requeries but no luck.

Hope this makes sense - any ideas?


Details

text box A control source  =funcAvoidErrorProductTotal([chdReport].[Report]![txtTotal],0)

Function funcAvoidErrorFixedTotal(varFixedTotal As Variant, varReplaceWith As Variant)

     On Error GoTo funcAvoidError_Error
     
     If PBcurFixTotal > 0 Then
        funcAvoidErrorFixedTotal = PBcurFixTotal
    Else
        funcAvoidErrorFixedTotal = Nz(varFixedTotal, varReplaceWith)
     
        If funcAvoidErrorFixedTotal > 0 Then
            PBcurFixTotal = funcAvoidErrorFixedTotal
        End If
    End If

funcAvoidError_Exit:
      Exit Function

funcAvoidError_Error:
      funcAvoidErrorFixedTotal = varReplaceWith
      Resume funcAvoidError_Exit

End Function
kenabbottAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

hnasrCommented:
Reproduce the issue in a sample database and upload.
0
Boyd (HiTechCoach) Trimmell, Microsoft Access MVPDesigner and DeveloperCommented:
kenabbott,

I use a different approved for reports like this. I create a totaling query that sums the same records as in the sun report(s). I this add this totaling query to the query for the main/parant report.  Use NZ() to handle when the sum() field is null when using the total in a calculation.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.