Tutorial updated for PostgreSQL lazarus / 16-Databases ---------------------------------------------------------------------- BigChimp · 2012-09-14 15:19 Hi all, I just updated the http://wiki.lazarus.freepascal.org/SQLdb_Tutorial1 for PostgreSQL. As always, reports on errors/omissions and possible improvements are more than welcome. Thanks a lot, BigChimp ---------------------------------------------------------------------- codifies · 2012-09-15 05:39 nice tutorial! where you say you haven't found a way to delete via a key stroke can you not have a key up event (might have to have a key up even for multiple components calling the same function - not sure if there is a global key up) procedure Tmyform.doDeleteKeyCheck(Sender: TObject; var Key: Word; Shift: TShiftState); begin   if (key=KEYVAL) then      query1.CancelUpdates;      query1.delete;      query1.applyUpdates;   end; end; or am I missing the point! ---------------------------------------------------------------------- BigChimp · 2012-09-15 07:31 No, that looks good. Never knew about the .Delete functionality. Too much SQL indoctrination too even consider it existed Now I'm searching like crazy where the delete key is defined. I vaguely remember I have to include some unit with keyboard codes but which one???! ---------------------------------------------------------------------- codifies · 2012-09-15 08:01 sorry you will have to define the delete sql property with something like delete from acme where acmeid=:acmeid it looks like you don't actually need to define the queries parameter for the key as I assume it just uses the first one in the sql it comes to.... ---------------------------------------------------------------------- BigChimp · 2012-09-15 08:08 Actually it seems to work fine as is (the query is simple enough so SQLDB can figure out the DELETESQL property contents). I actually meant the VK_DELETE keycode - have opened another topic on it: lazarus.freepascal.org/index.php/topic,18221 ---------------------------------------------------------------------- codifies · 2012-09-15 11:05 actually nix the cancelUpdates not only is it not needed it looks like it can stop delete from working, which is odd cause I'm sure it worked last night.... ---------------------------------------------------------------------- BigChimp · 2012-09-15 17:33 Quote from: chris_c on September 15, 2012, 07:39:30 amprocedure Tmyform.doDeleteKeyCheck(Sender: TObject; var Key: Word; Shift: TShiftState); begin   if (key=KEYVAL) then      query1.CancelUpdates;      query1.delete;      query1.applyUpdates;   end; end; Unfortunately, for the delete key (VK_DELETE) that must be tweaked because it currently deletes the record if you're editing a field and e.g. trying to delete a letter by pressing the delete key. Did this: Code: [Select]procedure TForm1.DBGrid1KeyUp(Sender: TObject; var Key: Word; Shift: TShiftState   ); begin   // Check for del key being hit and delete the current record in response   // as long as we're not editing data   if (key=VK_DELETE) and (not(DBGrid1.EditorMode)) then   begin     //... delete current record and apply updates to db:     SQLQuery1.Delete;     SQLQuery1.ApplyUpdates;   end; end; Suggestions for improvement welcome. ---------------------------------------------------------------------- codifies · 2012-09-15 17:51 LOL or is that DOH I think its acceptable to inhibit the delete key removal of a record while the focus is in an edit box... personally I'd use alt+d via a button keyboard shortcut - accelerators I think they used to be called...