Dataset not in Edit or Insert Mode

"Tor Anders Johansen" <m...@toranders.com> skrev i melding
news:5f88c910.0205160056.7266b12e@posting.google.com...

Quote
> Im trying to post changes back to the dataset before
> changing a filter:

> ---

> if (tlRegValue.DataSource.State in [dsEdit, dsInsert]) then

...should be:
  if (tlRegValue.DataSource.DataSet.State in [dsEdit, dsInsert]) then

Quote
>   tlRegValue.DataSource.DataSet.Post; // <- stops here!

> tlRegValue.DataSource.DataSet.CancelRange;
> tlRegValue.DataSource.DataSet.SetRangeStart;
> tlRegValue.DataSource.DataSet.FieldByName('KeyId').AsInteger := AKey;
> tlRegValue.DataSource.DataSet.SetRangeEnd;
> tlRegValue.DataSource.DataSet.FieldByName('KeyId').AsInteger := AKey;
> tlRegValue.DataSource.DataSet.ApplyRange;
> ---

> The problem is that I get an Error message saying
> "Dataset not in Edit or Insert Mode".

> But I thought this was the correct way to do this because
> the datasource sets the dataset to edit state!?

The datasource represents a layer that connects controls with datasets. I
don't know for sure what situations make datasource.state differ from the
underlying dataset's state, but I've allways been using the dataset itself.
*Especially* a check like you do, where DataSet.Post; causes an exception if
not in edit/insert state.

...btw, this is an example of code that would be much more readable when
using "With tlRegValue.DataSource.DataSet do..." or by assigning the dataset
property to a local variable. I actually had to look 3 times before I saw
what you had been doing...;-)

--
Bj?rge S?ther
bjorge@hahaha_itte.no