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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calculation on a field without changing the control source

Status
Not open for further replies.

PLK3541

IS-IT--Management
Mar 29, 2005
60
0
0
US
Hello,

I've got a text box in a sub form and on my form header with a calculation in the control source that adds values from other text boxes on my form.
My problem is that since the calculation is in the control source of my text box I can not save the sum of the calculation to a field on the forms bound table.
Is there a way to move this calculation out of the control source and still have the calculation populate this text box with the sum of the calculation, so I can choice a field in which to save this calculations sum.

Calculation in the sub form text box control source=[Purchase Orders Subform].Form!Text21
Calculation in the form text box control source=[UnitsOrdered]*[UnitPrice]


Thanks--Any help will be greatly appreciated.
 
You may set the value of the bound control to the value of the calculated one in the BeforeUpdate event procedure of the form.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
How are ya PLK3541 . . .

Calculations are not noramlly saved in a DB (uneccessary overhead). Since they'll always come out right, display is all thats necessary.

There are occasions when a calculated value needs to saved, but they are rare (forwarding a balance for a new bank statement as an example).

Just be aware of the overhead if you do decide to save.

Calvin.gif
See Ya! . . . . . .
 
The BeforeUpdate event procedure did not work for me. And I also tried to create a query that performs the calculation and then use =dsum("[Expr1]","[Inventory Transactions Query]") still did not place value in field.

This is the Purchase Order form I would love to run report and pull from the total field

 
PLK3541 . . .
PLK3541 said:
[blue]The BeforeUpdate event procedure did not work for me . . .[/blue]
Really! . . . [blue]PHV's[/blue] resolution should work. In the BeforeUpdate event of the form, you should have something like:
Code:
[blue]Me!BoundFieldName = Me!TextboxNameWithDSumCalc[/blue]
Post back what you have!

Calvin.gif
See Ya! . . . . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top