Board index » delphi » How to Make a Summary table from a table with Delph3 and Dbase3+ table

How to Make a Summary table from a table with Delph3 and Dbase3+ table

How to make a Summary table which has some fields extracted from the same
field of detail table?
Please give me a sample code...

my mail id is le...@chollian.net

For example

i have a table, called Detail table (detail.dbf)
Structure is
   field name            type      size      description
   ---------            -----    ----      -------------------
   dept                    string    2           department code
   title                     string    10          activities title
   SchStartDate       date                   scheduled start date
   SchEndDate        date                                   end  date
   ActualStrtDate     date                    actual  start date
   ActualEndDAte     date                              end date

 this table has the activities of all dept

and then i want to summarize the information
from this table using another summary table
what i want to summarize is
   1) how many activities are registered by each dept,
   2) how many activities are scheduled to finish by today by each dept
   3) how amny activieties are finished by today grouped by each dept
   4) how many activites are left
   5) finally how many activites are delayed until today

so i create another table called SumTbl  (SumTbl.dbf)
it's Structure is
   field name             type          size   description
   dept                     string         2       deprtment code
   cnt_Regi               integer       5       Count of Registered
   Cnt_Sch               integer       5       count of Scheduled
   Cnt_Finish            integer       5       Count of Finished by today
   Cnt_Remn            integer       5       Count of remain activites
   Cnt_Delay            integer       5       Count of Delayed activites

But i don't know how to make a summary table which should be updated while i
open the Summary Form  of my application
which mean i didn't add the code in the insert or update event of update
form to update summary table

Please Help me!
How to make a summary code like that.
Give me a sample code..
i tried several code but it failed finally.
i used "cached update and updateapplys", but it also failed
because of my weakness of delphi programing ability.

**What is the best way?
    and is it possible to make a SQL to make a summary table like that ?
if possible, Please give me a mail
  le...@chollian.net

 

Re:How to Make a Summary table from a table with Delph3 and Dbase3+ table


First, make calculated fields at design time.  You can do this by (Delphi 1)
double clicking the
TTable or TQuery component.  You will see a dialog box with Add, Define,
Remove, and Remove All buttons.  Add all the fields and then define a field.
There will be another dialog box to define the field.
Once you define the field, and hit ok, you will see your field in the list
in the first dialog box.  Click on it and hit F11.  The properties for this
field will show up in the object inspector.  Go to the event handlers in the
object inspector.  Where it says OnGetText, create a method that sets the
property of the Text parameter to the value of the field in the Master Table
that you mention.

e.g.
procedure TForm1.TableMasterField1GetText(Sender: TField;
  var Text: OpenString; DisplayText: Boolean);
begin
    Text := MasterTable.Fields[NameFieldIndex].AsString;
end;

Note that you have to be careful about how you set the calculated fields.
Since you have a Master/Detail setup  (where the selected Master record
entry would then update the Detail table entries)  you are guaranteed that
the current Master Record applies to the show Detail records.

Hope that helps,
Orlando

Quote
lee byeong don wrote in message <6gimqj$s...@forums.borland.com>...
>How to make a Summary table which has some fields extracted from the same
>field of detail table?
>Please give me a sample code...

>my mail id is le...@chollian.net

>For example

>i have a table, called Detail table (detail.dbf)
>Structure is
>   field name            type      size      description
>   ---------            -----    ----      -------------------
>   dept                    string    2           department code
>   title                     string    10          activities title
>   SchStartDate       date                   scheduled start date
>   SchEndDate        date                                   end  date
>   ActualStrtDate     date                    actual  start date
>   ActualEndDAte     date                              end date

> this table has the activities of all dept

>and then i want to summarize the information
>from this table using another summary table
>what i want to summarize is
>   1) how many activities are registered by each dept,
>   2) how many activities are scheduled to finish by today by each dept
>   3) how amny activieties are finished by today grouped by each dept
>   4) how many activites are left
>   5) finally how many activites are delayed until today

>so i create another table called SumTbl  (SumTbl.dbf)
>it's Structure is
>   field name             type          size   description
>   dept                     string         2       deprtment code
>   cnt_Regi               integer       5       Count of Registered
>   Cnt_Sch               integer       5       count of Scheduled
>   Cnt_Finish            integer       5       Count of Finished by today
>   Cnt_Remn            integer       5       Count of remain activites
>   Cnt_Delay            integer       5       Count of Delayed activites

>But i don't know how to make a summary table which should be updated while
i
>open the Summary Form  of my application
>which mean i didn't add the code in the insert or update event of update
>form to update summary table

>Please Help me!
>How to make a summary code like that.
>Give me a sample code..
>i tried several code but it failed finally.
>i used "cached update and updateapplys", but it also failed
>because of my weakness of delphi programing ability.

>**What is the best way?
>    and is it possible to make a SQL to make a summary table like that ?
>if possible, Please give me a mail
>  le...@chollian.net

Re:How to Make a Summary table from a table with Delph3 and Dbase3+ table


thanks for your helpness,
But i want to know is How to extract several data with diffierent criteria
from a table(DBase3+) and then how to update these data to a summary
Table(alse DBase3+) with Delphi3?
How to?
i really want to know is 1) which componets are used
2) if SQL(TQuery is used), How many TQuery components are needed?
3) and then What is the SQL
4) if possible, i want less TQuery Components used
5) Is there another way to do like this except TQuery or Ttable?
6) Finally, Give me a sample code!!!!
until now i can't get any idea...
Please help me!.

Orlando Pobre (?) <6gjr8c$...@forums.borland.com> ?T??????-
??o?????...

Quote
>First, make calculated fields at design time.  You can do this by (Delphi
1)
>double clicking the
>TTable or TQuery component.  You will see a dialog box with Add, Define,
>Remove, and Remove All buttons.  Add all the fields and then define a
field.
>There will be another dialog box to define the field.
>Once you define the field, and hit ok, you will see your field in the list
>in the first dialog box.  Click on it and hit F11.  The properties for this
>field will show up in the object inspector.  Go to the event handlers in
the
>object inspector.  Where it says OnGetText, create a method that sets the
>property of the Text parameter to the value of the field in the Master
Table
>that you mention.

>e.g.
>procedure TForm1.TableMasterField1GetText(Sender: TField;
>  var Text: OpenString; DisplayText: Boolean);
>begin
>    Text := MasterTable.Fields[NameFieldIndex].AsString;
>end;

>Note that you have to be careful about how you set the calculated fields.
>Since you have a Master/Detail setup  (where the selected Master record
>entry would then update the Detail table entries)  you are guaranteed that
>the current Master Record applies to the show Detail records.

>Hope that helps,
>Orlando

>lee byeong don wrote in message <6gimqj$s...@forums.borland.com>...
>>How to make a Summary table which has some fields extracted from the same
>>field of detail table?
>>Please give me a sample code...

>>my mail id is le...@chollian.net

>>For example

>>i have a table, called Detail table (detail.dbf)
>>Structure is
>>   field name            type      size      description
>>   ---------            -----    ----      -------------------
>>   dept                    string    2           department code
>>   title                     string    10          activities title
>>   SchStartDate       date                   scheduled start date
>>   SchEndDate        date                                   end  date
>>   ActualStrtDate     date                    actual  start date
>>   ActualEndDAte     date                              end date

>> this table has the activities of all dept

>>and then i want to summarize the information
>>from this table using another summary table
>>what i want to summarize is
>>   1) how many activities are registered by each dept,
>>   2) how many activities are scheduled to finish by today by each dept
>>   3) how amny activieties are finished by today grouped by each dept
>>   4) how many activites are left
>>   5) finally how many activites are delayed until today

>>so i create another table called SumTbl  (SumTbl.dbf)
>>it's Structure is
>>   field name             type          size   description
>>   dept                     string         2       deprtment code
>>   cnt_Regi               integer       5       Count of Registered
>>   Cnt_Sch               integer       5       count of Scheduled
>>   Cnt_Finish            integer       5       Count of Finished by today
>>   Cnt_Remn            integer       5       Count of remain activites
>>   Cnt_Delay            integer       5       Count of Delayed activites

>>But i don't know how to make a summary table which should be updated while
>i
>>open the Summary Form  of my application
>>which mean i didn't add the code in the insert or update event of update
>>form to update summary table

>>Please Help me!
>>How to make a summary code like that.
>>Give me a sample code..
>>i tried several code but it failed finally.
>>i used "cached update and updateapplys", but it also failed
>>because of my weakness of delphi programing ability.

>>**What is the best way?
>>    and is it possible to make a SQL to make a summary table like that ?
>>if possible, Please give me a mail
>>  le...@chollian.net

Other Threads