Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to force fields to calculate?

Status
Not open for further replies.

TimSNL

Programmer
Sep 11, 2001
119
AU
Hello

Is there a way to tell a dataset to recalculate its Calculated Fields?
 
Try the [tt]Refresh[/tt] property - viz:
[tt]MyDataset.Refresh; // this assumes the table is open[/tt]

Alternatively, you could [tt]Close[/tt] then [tt]Open[/tt] the table again (particularly with a query!)- viz:
[tt]
with MyQuery do begin
close;
// do something
open;
end;
[/tt]

As the Refresh help says:

Note: The Refresh method does not work for all TDataSet descendants. In particular, TQuery components do not support the Refresh method if the query is not “live”. To refresh a static TQuery, close and reopen the dataset.


Should work with calculated fields. But a big database may cause some slow access.

The other way might be to use a [tt]BeforeScroll[/tt] event - assuming your raw data is not changing.

Cheers


Chris ;-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top