Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calculations

Status
Not open for further replies.

livvie

Programmer
Apr 20, 2004
91
IE
Hi All
Here is what I am trying to do.
x = (Q*U)*Q2
X2 = Sum(each instance of x)
Basically I am calculating a cost figure whic is x that is no problem but then if there is more than one x I want to add them together .
Any bright ideas. I have tried loops but it is hard to get a condition that works.
 
Depends where you are doing it.

If U V and Q2 are fields in a table then use a Group By clause in a query

If they are cotrols on a report then use a dummy control to calc X and set the Running Sum to OverGroup or OverAll ( as appropriate )

If they are controls on a form then run some code to do the sum in resoponse to U V and Q2 's After_Update events



'ope-that-'elps.

G LS
spsinkNOJUNK@yahoo.co.uk
Remove the NOJUNK to use.
 
If this is done strictly in code, then:
x = (Q*U)*Q2
X2 = X2 + x 'Sum(each instance of x)

Each time the X calculation fires then it will be added to X2.

Regards
Rod
 
Rod
X2 seems to loose the value you see I am leaving the module to enter more data and then returning. How do I save X2 until I return to the module
 
Got it thanks.
Solution
MyMatCost = (Me.txtMatQty.Value * Me.txtmatcost.Value)
If Me.Parent!txtmatcost > 0 Then
MyMatCost2 = Me.Parent!txtmatcost
Else
Me.Parent!txtmatcost = MyMatCost
End If

MyMatCost2 = (MyMatCost2 + MyMatCost)
Me.Parent!txtmatcost = MyMatCost2
 
Problem now is that if the user goes back and changes a value this value is added on too but the old needs to be removed. Any bright ideas ?
 
Can belive I have been so silly. made the problemd more difficult than it is. Sorted now thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top