View Full Version : Calculations for Unbound Textboxes


amerfeld
01-04-2006, 09:42 AM
Hi all:
I have searched for a solution to this but haven't found quite what I need. I have a report with an OrderNo header and footer. There is an unbound textbox in the detail section which calculates a value using the code below. The code runs at the onformat event of the detail section. Here is the code for the unbound textbox (named txtTtlMin):

If CstDesc = "masking" Then
txtTtlMin = PPMMPP * ReceiptQty
ElseIf CstDesc = "prefinish" Then
txtTtlMin = PPMMPP * ReceiptQty
Else
txtTtlMin = ReceiptQty / PPMMPP
End If

This works fine. What I need to do is calculate the sum of the txtttlmin textbox in the order no footer section. Not sure how to do this. Can anyone help? Thanks.

amerfeld
01-05-2006, 06:29 AM
Someone, puhleeeeeeeese, must know the answer to this one. If you need clarification, let me know. Thanks!:)

Rich
01-05-2006, 12:38 PM
I don't see the point of using vba to do this, a calculated control will do the same.
To sum the control you need to repeat the calculation ie
Sum([Item]*[Quantity] or use the running sum property of a hidden textbox

amerfeld
01-06-2006, 07:01 AM
Rich:
Thanks for your reply. If you look at the code again, you'll see the calculation is dependent upon what type of operation is being used. Any other ideas?

Rich
01-06-2006, 07:07 AM
A calculated expression with an Iif statement will do the same thing, to Sum them you just need Sum(Iif + Sum(Iif etc or again an unbound hidden textbox with the RunningSum property set to overall

amerfeld
01-06-2006, 07:25 AM
Rich: Apparently I haven't had enough coffee yet this morning and need you to please spell things out for me. For the calculated expression, do I need to put that in a control or in the footer section under the onformat event? Also, not quite sure how the hidden unbound control ties in. I haven't really ever used an IIF statement so I think this is where my knowledge is lacking (maybe in several other areas as well :) )Thanks again!

Rich
01-06-2006, 08:12 AM
=Sum(Iif(([CstDesc] = "masking" Or "prefinish" ),[PPMMPP] * [ReceiptQty],[ReceiptQty] / [PPMMPP]))

amerfeld
01-06-2006, 08:33 AM
Thanks Rich. Before you replied, I went into the underlying query and created a field with a nested IIF statement to use instead of the unbound control in the detail section of the report. Then on the report, because I now had a control with a control source, I was able to sum the control in the footer section. (Hope that makes sense for anyone following). All is happy now. Thanks again.