Board index » cppbuilder » TDBCtrlGrid - problem

TDBCtrlGrid - problem


C++Builder 4 professional with both patches applied.
MSSQL 7.0 via ODBC
TDBCtrlGrid in a Master / Detail relationship.

When using TDBCtrlGrid relating to a single table it works OK from panel to

When using TDBCtrlGrid in a Master / Detail relationship with the following
   1. The Grid relates to the "detail dataset" being sales order lines
whilst the master is the sales order header.

   2. Some of the Data Aware components located in the panel require
calculation based on values entered and are also stored into the database
row i.e. Gross = Qty * Price - all three fields are stored in the database.
  3. The calculations are done on Exit from each of the Entry fields.

The problem manifests itself when the first panel is completed and the
cursor moves to the second panel:

    The second panel contains the same data as the first panel. (Should be
    The cursor is positioned on the first "data aware" component of the
first panel. (Instead of the second panel)
    When trying to overtype the field a message "Couldn't perform the edit
because another users changed the record" was
                received. I am the only one working on the system.
    Tabbing to panel 2 I am then able to overtype the content.
    "Refreshing" the dataset (without tabbing to panel 2) "disposes" of the
2nd panel and positions the cursor on the first panel                 in the
first field.

Trust you can help a desparate man.

Graham Smith


Re:TDBCtrlGrid - problem

Hi, Graham!

I strongly recommend that rather that being control oriented in your
calculations that you perform the calculations in your data set in the
OnCalcFields handler.

To use calculated fields, double-click on the dataset, right click on
the window that shows, pick add fields, add all of the fields; then
right click on that window again, pick new field, and create a
calculated field of the appropriate type. Then, in your dataset
OnCalcFields handler, access the field (let's say you called it
CalcResult) as

    DataModule1->CalcResult.AsDouble = Somecalculation();

Add the calculated field to your control grid, and you will notice
everything updating neatly.

If you have fields of this sort which must be stored in the database,
the BeforePost event handler of the dataset is the place to do it.

Finally, you may wish to ask questions relating to databases and
database-related components in
borland.public.cppbuilder.database.desktop; more database knowledgable
folks tend to be available there.

Hope this helps.

Mark Cashman, TeamB C++ Builder
C++ Builder, JBuilder programming information
Home of The C++ Builder Programmer's Webring - Join us!

Other Threads