Subform Footer Totals Problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • csolomon
    New Member
    • Mar 2008
    • 166

    Subform Footer Totals Problem

    Happy Friday!

    I was wondering if you can have more than one total in the footer. I ask this because when I set up one of my totals in the footer (lets call it total1), it works (slowly but it works)...but when I set up the other one (total2), I get an error for the total1 value and an error for the total2 value.

    I have a function, GetYield, that returns a calculation based on the material chosen (matType).
    Public Function GetYield(matTyp e As Integer, BatchWeight As Double, MatGrav As Double) As Double
    'returns the yield of each material 'DM_yield' calculation

    Select Case matType
    'Cement, Coarse, Fine, Pigment
    Case 1, 2, 3, 4
    GetYield = BatchWeight / (MatGrav * 62.4)
    'Chemicals
    Case 5
    GetYield = (BatchWeight / 128) * (10 / 62.4)
    Case Else
    GetYield = 0
    End Select
    End Function

    I call this function in a query, which is the control source for the subform:
    SELECT MixSample.DM_Mi x, MixSample.DM_Ma terialNo, MixSample.matTy peID, MixSample.mater ialID, MixSample.matBa tchWeight, MatType.matType , Material.materi al, Material.materi alGrav, GetYield([MixSample].[matTypeID],[matBatchWeight],[materialGrav]) AS DMYield, MixSample.pigPe rcent FROM MixDesign INNER JOIN (Material INNER JOIN (MixSample INNER JOIN MatType ON MixSample.matTy peID = MatType.matType ID) ON Material.materi alID = MixSample.mater ialID) ON MixDesign.DM_Mi x = MixSample.DM_Mi x;

    I have a bound text box on my subform whose control source is the calculated field in the query, called DMYield.
    In my footer, I have an unbound text box, txtSumDMyield, that is supposed to get the total sum of the DMyield field (named DM_yield) in the form. the control source of the txtSumDMYield field is:
    =Sum([DMyield]), which only sometimes returns a value.
    Currently, it is not returning any thing...

    When I tried to include an unbound text box which also calculated the sum of another field on the form, total1 stopped working and gave me a #error, along with the total2 value equaling #error. total2's sontrol source was similar to total1, =Sum([DM_MixCost]). The unbound text box for DM_MixCost value is also determined by a function. The function returns correct values, but when it comes to getting a total sum for them, I get an error.

    Any ideas how I can get BOTH totals working?

    Thank you
  • csolomon
    New Member
    • Mar 2008
    • 166

    #2
    I figured it out, thanks!

    Comment

    Working...