Thanks for the code madref, some useful learning points as well
I'd actually ended up doing this as suggested earlier.
Query.Refresh;
SQLQuery8.SQL.Text := 'SELECT MAX(ID) AS MaxID FROM ' + Table;
SQLQuery8.Open;
Query.Locate('ID', SQLQuery8.FieldValues['MaxID'], []);
SQLQuery8.Close;
What I still can see is when I do an insert into a DBGrid the ID is always Null in events like AfterPost, AfterInsert, etc, so I'm not sure when to catch the record to get the latest ID just inserted, would it be BefortPost?
A quick Off-topic for you to help me.
I'm interested in your use of:
mySql.SQL.Text := Format('SELECT %s FROM %s WHERE %s', [veld, tabel, voorwaarde]);
I'd been trying to use
mySQL.SQL.Text := 'SELECT :FieldName FROM :TableName GROUP BY :FieldName';
mySQL.Param.ParamByName ('TableName').Value := 'Name';
mySQL.Param.ParamByName ('FieldName').Value := 'Name';
But I always get an error. I guess you can't do this, but if you need to do it then your way is the way
Thanks for the learning
Dave