This is what I am doing now. In the following code, DSMaster is the master,
DSChild is the nested one, "Items" is the data set field, and "ItemCount" is
the calculated field. Here is my OnCalcFields handler for DSMaster:
void __fastcall TForm1::DSMasterCalcFields(TDataSet *DataSet) {
DSMaster->FieldByName("NItems")->AsInteger =
DSChild->RecordCount;
}
For some reason doing this cause duplicate records to appear in DSMaster's
DBGrid control. It does not add duplicate records to the database, but
rather, creates many row in the DBGrid that all reference the same record
(i.e. edit one and the change shows up in all the copies). The duplication
appears somewhat random but is somehow related to how I use the vertical
scroll bar in the DBGrid control.
Questions:
1) How do I do what I'm trying to do -- that is, display the number of
records in a nested data set in a calculated field of the master data set?
2) How do I access the TClientDataSet of a TField that is a data set? There
is AsInteger, AsString, etc., but no AsDataSet? Without being able to do
this I can not calculate fields in OnCalcFields using only the TDataSet*
passed to the function, I must use some variables from outside the function
as well (e.g. using DSChild in the above example).
3) Is this not the right newsgroup for questions about TClientDataSets? The
borland.public.cppbuilder.database.desktop newsgroup is all but dead, and
none of the other borland.public.cppbuilder.database.* groups looked
appropriate. This -is- a VCL component, and as a matter of fact it's one of
my favorites, but nobody seems to know much about it. From what I've read
TClientDataSet was only recently moved from Enterprise to Professional
edition so maybe it's a mystery to everybody, still.
Thanks,
Jason
>3) Is this not the right newsgroup for questions about TClientDataSets? The
ask in .datasnap and .delphi.database.multi-tier
--
Vladimir Ulchenko aka vavan
"vavan" <Vavan...@ThisSantel.ru> wrote in message
news:v32gq3dlukgstgdpk...@4ax.com...