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

How to Create a Calculation field in design time ?

Status
Not open for further replies.

essnrv

Programmer
Jun 27, 2002
229
IN
Hi All,

I need to add a field, which holds the results of other two fields.
E.g.
Field 1- Quantity
Field 2 - Cost
Field 3 - Total Value (Quantity * Cost)

How can I create Total Value field ?
 
Hi,
It appears that there are at least 2 different ways of accomplishing this task. The first solution is performed inside of a form, where the TotalValue field is "locked". This field is calculated in the "AfterUpdate" event of the Cost field. Essentially then, this is being calculated every time a new record is being added.

The second technique is to create an update query. In the first column of the query is the field you wish to update (TotalValue). You would have two additional fields in the query (these are Quantity and Cost). In the "Update to:" row of the TotalValue column, simply use this code: Quantity*Cost
When you run this, each record will be examined, and the calculation will be made. If either value is zero, the result will be zero (but then, you already knew that!!) :)

HTH,
Randy Smith
California Teachers Association
 
Hi,
I just realized that you only wanted to do this in "design time" (it's only mentioned in the thread title). Actually, I don't have a solution for that. Of course, the update query that I explained can be run anytime. HTH,
Randy Smith
California Teachers Association
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top