Hi all,

I've developed a little app. using MySQL via dbExpress, that contains the following objects:
- datamodule (with Tsqlconnection, TSQLDataSet, TDataSetProvider and a TClientDataSet),
- form (with a pagecontrol - two tabs: overview and detail), button 'Insert', action (DataSetInsert) and a TDataSource.

The tab 'Overview' contains a dbgrid (readonly := true) that's filled with all the records of a table. The tab 'Detail' contains two dbEdits.
The button has one action connected to it. And that's a DataSetInsert (a built-in action of Delphi).

When I scroll (by mouse or keys) through the dbgrid and hit the button, it activates the Detail-tab and inserts a new blank record. So far so good. Everything just works fine.

Now when I add a toolbar to the form, add a button (TToolButton) on the bar and connect the action DataSetInsert to the toolbutton, the app won't work when I want to insert a new record after I've been scrolling through the grid.

The app does a Insert, immediately followed by a Browse.

When going into Insert is handled by the OnStateChange of the TDataSource (which is connected to the TClientDataSet on the datamodule). The event only contains the following code:

if dtsMain.State in [dsInsert] then begin
pagecontrol1.ActivePageIndex := 1;

The OnNewRecord-event of the ClientDataSet only contains code to get the highest number, add 1 to it and put it in a field of the clientdataset.

REMARK: all of this code works when using the TButton to insert a record. When using the button on the toolbar, it gives the following error: DataSet not in Edit or Insert mode.

The problem not only arises by using TToolbar, it also happens when using the ActionBar (TActionManager).

Anyone an idea of what's going wrong?

Thnx in advance.