?
Solved

Calculated fields

Posted on 1998-05-06
4
Medium Priority
?
472 Views
Last Modified: 2010-04-06
I need to know how to create a calculated field that uses a second calculated field that
is contained in a dbgrid.  What I'm looking for basically is for a sum of a grid column
which is itself a calculated field.
0
Comment
Question by:AllenD
[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
  • 2
4 Comments
 
LVL 8

Accepted Solution

by:
ZifNab earned 50 total points
ID: 1342529
Hi AllenD,

What's the problem? Or am I missing something?

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  DBTables, DB, Grids, DBGrids;

type
  TForm1 = class(TForm)
    Table1: TTable;
    DataSource1: TDataSource;
    DBGrid1: TDBGrid;
    Table1SpeciesNo: TFloatField;
    Table1Category: TStringField;
    Table1Common_Name: TStringField;
    Table1SpeciesName: TStringField;
    Table1Lengthcm: TFloatField;
    Table1Length_In: TFloatField;
    Table1Notes: TMemoField;
    Table1Graphic: TGraphicField;
    Table1Calculate1: TFloatField;
    Table1Calculate2: TFloatField;
    procedure Table1CalcFields(DataSet: TDataSet);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Table1CalcFields(DataSet: TDataSet);
begin
 with Table1 do begin
  FieldByName('Calculate1').AsVariant := 25;
  FieldByName('Calculate2').AsVariant := FieldByName('Calculate1').AsFloat * 2;
  end;
end;

end.

Regards, ZiF.
0
 

Author Comment

by:AllenD
ID: 1342530
Hi Zif!

The problem I'm having is the second calculated field that operates on the first one is in a different table.  What I'm trying to do is make a running grand total of a line total.  ( I know it's kind of confusing)....to give you a general idea...here's a layout of what I want.

Quantity | Part Number | Price | Line total
3           | 1000             | 5.00  | 15.00                  <= in a dbgrid  Table1
3           | 2000             | 10.00| 30.00


                                     Parts Total        45.00      <= outside the grid. Table2


I hope this gives you a better idea of what I want.
Thanks

Al.
0
 

Author Comment

by:AllenD
ID: 1342531
Not QUITE what I was Looking for...but it gave me the ideas to be able to fix my code...thanks
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1342532
Seems to me you solved it already ....
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

801 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