Board index » delphi » Runtime error 216 / Dataset not in Insert/Edit Mode

Runtime error 216 / Dataset not in Insert/Edit Mode

My Application is intermittently bombing on the following code in the
"Recall Form"

  Datamodule1.TBWSale.Active:=False;
  Datamodule1.TBWSale.Tablename:='WsaleS.DB';
  Datamodule1.TBWSale.Active:=True;  <<< THIS CAUSES THE CRASH >>>

        The program issues an error "Dataset not in insert/edit mode" when I
try to open the table. Upon program termination I also get a runtime
error 216.

        After playing with the program, I find that this problem only occurs
when another unit "WSBill" has its form created ( but not shown - all
forms are shown with showmodal only ). If I manually create and destroy
form "WSBill", this problem disappears. Form "WSBill" has a bunch of
data-aware controls which connect to TBWSale.

        Can anybody tell me what Delphi is doing ??? I'd really prefer to
autocreate Form "WSBill" rather than manually creating it due to the
speed of opening the window.

        Thank you for your help.

        Sincerely,

        Neil Huhta

 

Re:Runtime error 216 / Dataset not in Insert/Edit Mode


Quote
>    The program issues an error "Dataset not in insert/edit mode" when I
> try to open the table. Upon program termination I also get a runtime
> error 216.

>    After playing with the program, I find that this problem only occurs
> when another unit "WSBill" has its form created ( but not shown - all
> forms are shown with showmodal only ). If I manually create and destroy
> form "WSBill", this problem disappears. Form "WSBill" has a bunch of
> data-aware controls which connect to TBWSale.

Somewhere on form WSBill an OnChange type event is trying to change the
contents of a field in your table. Try setting WSBill's
DataSource.Enabled to False in the form designer, then set it to True in
the FormShow event and False in the FormClose event.

Runtime error 216 is an access violation. Is an exception raised? Also -
make sure Datamodule1 is created before form WSBill.

Re:Runtime error 216 / Dataset not in Insert/Edit Mode


John:

        Thank you so much for your insight !!! I suspect that my incremental
combo control is firing its on change event and will test things
accordingly.

        This same problem is also occurring within the WSBill form itself which
further confirms this assertion.

        I will either A) test for an open dataset in the onchange event,
        B) Temporarily remove the offending onChange event during the process,
or C) Disable the controls during this procedure.

        Thank you very much.

Sincerely,

Neil Huhta

Other Threads