Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Calculated Fields - How to

Posted on 1998-10-27
3
Medium Priority
?
286 Views
Last Modified: 2010-04-06
Simple question. How do I define and access a calculated field in a table.

I have two field values i want to multiply, with the total going in the calculated field.

Thanks.
0
Comment
Question by:DougBennett
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 

Accepted Solution

by:
pc_melsa earned 20 total points
ID: 1344652
To add calculated fields, use the field editor, which is accessed by double clicking the TTable Component. Select the Define button, you'll nee to supply a new field name and the data type of the field.
Delphi 2,3 executes the procedure in the OnCalcFields event handler whenever there is need to recalculated field.
While in the OnCalcFields event handler, the dataset will be in dsCalcFields state.

Here is the example :

procedure MyForm.InventoryCalcFields(Dataset: TDataSet) ;
VAR
   CurrentPrice, LbsPerYard, YardsInStock : double ;
BEGIN
   CurrentPrice := MyTable['CostPerYard'].AsFloat ;
   LbsPerYard   := MyTable['LbsPerYard'].AsFloat ;
   YardsInStock := MyTable['CubicYards'].AsFloat ;

    // Assign value to the fields that are calculated
   MyTable['MarketValue'].AsFloat := CurrentPrice * YardsInStock ;
   MyTable['LbsInStock'].AsFloat := LbsPerYard * YardsInStock ;
END ;


Hope you'll satisfied.
0
 

Expert Comment

by:pc_melsa
ID: 1344653
Thank you very much !
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question