Board index » delphi » Calc.Field=Calc.Field * Field ?

Calc.Field=Calc.Field * Field ?

IB6,D6
Components : SqlQuery+DataSetPrv.+ClientDataset

Table1
TRS ( Transfer Quantity from last year, Regular.Field )
INCOM ( Income Quantity , Reg.field)
OUTGO ( Outgoing Quantity, Reg.field )
STOCK ( Calculated Field) = TRS + INCOM - OUTGO

Table2
LASTPRICE  ( Regular Field )

i need another Calculated Field ( TOTAL )
TOTAL( calc.field) = STOCK( calc.field) * LASTPRICE ( regular field)

is it possible ?

Thank you.

 

Re:Calc.Field=Calc.Field * Field ?


Are table1 and table2 related? If so, by what field? Is the
relationship one-to-one? Is Stock a calculated field of the
ClientDataSet (is it calculated in the CDS's OnCalcFields event
handler)?

On Mon, 15 Jul 2002 00:18:11 +0300, "Henry Olive" <z...@zedltd.com>
wrote:

Quote
>IB6,D6
>Components : SqlQuery+DataSetPrv.+ClientDataset

>Table1
>TRS ( Transfer Quantity from last year, Regular.Field )
>INCOM ( Income Quantity , Reg.field)
>OUTGO ( Outgoing Quantity, Reg.field )
>STOCK ( Calculated Field) = TRS + INCOM - OUTGO

>Table2
>LASTPRICE  ( Regular Field )

>i need another Calculated Field ( TOTAL )
>TOTAL( calc.field) = STOCK( calc.field) * LASTPRICE ( regular field)

>is it possible ?

>Thank you.

--
Bill (TeamB)
(TeamB cannot respond to questions received via email)

Re:Calc.Field=Calc.Field * Field ?


Thank you for answering.

d6(int) ,ib6 , Components (SqlQuery+DSP+CDS+DS+DbGrid)

Table1  ( Parts)
----------------------
PartNo* ( P.Key )
PartName
LastPrice
...

Table2  (Items)
---------------------
OrdNo*
ItemNo*
PartNo
Trs
Incom
OutGo
.....
(OrdNo,ItemNo=P.KEY)

I want  a query result like below
( Stock=Trs+Incom-OutGo   -   Total = Stock*LastPrice )

PARTNO    PARTNAME    STOCK    LASTPRICE    TOTAL
----------------------------------------------------------------------------
----------
10-1000      AAAAA               10           18,000             180,000
10-1001      BBBBB                  4           25,000            100,000

Thank you.

Re:Calc.Field=Calc.Field * Field ?


Are you saying that you want the Total calculated field to be a
calculated field of the ClientDataSet for Table2?

On Mon, 15 Jul 2002 06:24:24 +0300, "Henry Olive" <z...@zedltd.com>
wrote:

Quote
>Thank you for answering.

>d6(int) ,ib6 , Components (SqlQuery+DSP+CDS+DS+DbGrid)

>Table1  ( Parts)
>----------------------
>PartNo* ( P.Key )
>PartName
>LastPrice
>...

>Table2  (Items)
>---------------------
>OrdNo*
>ItemNo*
>PartNo
>Trs
>Incom
>OutGo
>.....
>(OrdNo,ItemNo=P.KEY)

>I want  a query result like below
>( Stock=Trs+Incom-OutGo   -   Total = Stock*LastPrice )

>PARTNO    PARTNAME    STOCK    LASTPRICE    TOTAL
>----------------------------------------------------------------------------
>----------
>10-1000      AAAAA               10           18,000             180,000
>10-1001      BBBBB                  4           25,000            100,000

>Thank you.

--
Bill (TeamB)
(TeamB cannot respond to questions received via email)

Re:Calc.Field=Calc.Field * Field ?


Quote
> Are you saying that you want the Total calculated field to be a
> calculated field of the ClientDataSet for Table2?

Yes

Thank you.

Re:Calc.Field=Calc.Field * Field ?


Just add a calculated field named Total using the Fields Editor and
add the following to the OnCalcFields event handler.

with Table2 do
  FieldByName('Total').AsInteger := (FieldByName('Trs').AsInteger +
FieldByName('Incom').AsInteger - FieldByName('OutGo').AsInteger) *
FieldByName('LastPrice').AsInteger;

On Mon, 15 Jul 2002 23:11:37 +0300, "Henry Olive" <z...@zedltd.com>
wrote:

Quote
>> Are you saying that you want the Total calculated field to be a
>> calculated field of the ClientDataSet for Table2?

>Yes

>Thank you.

--
Bill (TeamB)
(TeamB cannot respond to questions received via email)

Other Threads