inserting a record in a grid on a form with a query data source

I have a fairly simple form with a grid on it. The data source for the form is an AOT query. That query has one main table (table A) and two joined tables (tables B and C). The data source property for the grid is set to table A.

The purpose of the form is to display table A, with a couple of fields pulled from tables B and C for reference, and allow the user to edit table A and insert & delete records in table A.

This works fine, except that trying to do an insert from the grid appears to be trying to insert a new record into table B, in addition to table A. (I have verified this by putting a breakpoint in the validateWrite() method on table B.)

I’m not sure if I should even be able to do this or not. Does anyone have a clue what I might be missing here? Do I need to change something in the query, or on the form? Deleting, by the way, works fine: the record will be deleted from table A, and the records in table B & C are left alone.

Thanks in advance for any help!

This is normal behavior of joined data sources. You have to override write() method of the child data sources and not to call super() there. You may also want to always return true from validateWrite().

Such a pattern is used by InventDim data source in PurchLine form, for example.

Thanks, Martin. I overrode write() to comment out super(), and validateWrite() to comment out super() and return true.

That seems to have done it!