Topic: Out of interest question on tablegrid oncell click
I have a table grid which is filled using a SQL statement - purely because the data comes from multiple tables.
The table is read only. The idea is that via scrolling or a search, an item is found, and when clicked on, the row appears in a number of text edits ready for editing.
My first attempt in the OnCellClick procedure was:
frmEditPart.edtEditDescription.Text := sqlexecute('SELECT description FROM productsupplier WHERE id=' +intToStr(frmEditPart.grdEditPart.dbItemID));
Now, that produces a -1 on the first click on the cell, but works correctly after that.
So I experimented with :
frmEditPart.edtEditDescription.Text := sqlexecute('SELECT description FROM productsupplier WHERE id=' +(frmEditPart.grdEditPart.sqlvalue));
That produces a NULL on the first click and then works as expected after that.
I worked around the problem by
frmEditPart.edtEditDescription.Text := frmEditPart.grdEditPart.Cells[1,Arow];
However, I'm puzzled as to why the previous two attempts produce this NULL.