Question on order of events lazarus / 16-Databases ---------------------------------------------------------------------- daveinhull · 2019-01-29 13:05 Hi all, Just a quick question on the order of events in a DBGrid. I have a dropdown box overlaid on a column in  DBgrid and when the user leaves the column the exit column event is triggered so that I can make sure that what was selected in the dropdown box is put in the grid and this works fine if I tab right. However if I jump using the mouse to another row the post even is triggered before the column exit event and then when it gets into the column exit the sekectedfield is fir the new row rather than as would be expected/required for the column/row that was exited. Firstly, is this the right order as I would have expected the exit column to trigger before the post event, and if it is, is there anyway to handle exit col for tabs and jumping to bew lines in the same way, or detect that a different trigger caused the exit column event? Thanks Dave ---------------------------------------------------------------------- balazsszekely · 2019-01-29 13:08 Set the post event to nil before edit, only re-assign it on the column exit event. In other words prevent the post until the column exit is called. ---------------------------------------------------------------------- daveinhull · 2019-01-29 14:57 Hello GetMem, Thanks for the suggestion, which I tried, but it still doesn't work. I set the reference to after post to blank in the object inspector Then at the end of column exit I pointed it back to the after post routine Then at the end if the after post routine set it to nil again. However the post still goes ahead and the selected field is the new one not the old one when it goes into column exit. Maybe I need to switch of automatic posting when it changes rows, but I've got all the SQLQuery options already switch off, so I'm not sure how to do this. Dave ---------------------------------------------------------------------- balazsszekely · 2019-01-29 15:10 TSQLQuery has an OnBeforePost event, you should call the same code which is executed at OnColumnExit. I would move the code from OnColumnExit to a separate procedure and call it from OnBeforePost or OnColumnExit respectively. You can also set a global boolean variable to prevent multiple calls. ---------------------------------------------------------------------- daveinhull · 2019-01-29 15:38 That's exactly what I did, but nevertheless the order doesn't seem right! Thanks for your help Dave ---------------------------------------------------------------------- balazsszekely · 2019-01-29 16:45 Can you attach a small demo? I really don't want code a whole database application, just to recreate this particular situation. ---------------------------------------------------------------------- daveinhull · 2019-01-29 17:43 Yes, give me a little time. I'm using MS Access is that ok? ---------------------------------------------------------------------- balazsszekely · 2019-01-29 18:20 Quote I'm using MS Access is that ok?No.  I don't use MS Access. I will try to simulate your situation with a firebird database. ---------------------------------------------------------------------- daveinhull · 2019-01-29 19:29 ok, I've made a small test example so if you can get the MS ODBC connect to access then you could try it, but if not you can see what I've done. Many thanks ---------------------------------------------------------------------- balazsszekely · 2019-01-29 20:07 It looks to me that the OnBeforePost trick works or perhaps I misunderstood something? Please test attached project. ---------------------------------------------------------------------- daveinhull · 2019-01-29 21:05 Hi GetMem, Yes I know it does as I said in an earlier post, I had already done it before you came back to me with it. I thought you wanted the test program to see what was going on with s view of proposing a change in the order. Anyway, Thanks for your help Dave ---------------------------------------------------------------------- balazsszekely · 2019-01-30 05:44 QuoteI thought you wanted the test program to see what was going onI did test the program, unfortunately I cannot find a better way to achieve the same thing. Implementing another event at database level would be the ideal solution in my opinion. For example an event called CanScrollOnEdit, which would pass a boolean parameter, like this: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.SQLQuery1CanScrollOnEdit(DataSet: TDataSet; var ACanScroll: Boolean);begin  ACanScroll := //allow scroll if some condition are metend;In my programs(for similar reasons) I never edit a grid, I only use it for navigation and displaying information. QuoteThanks for your helpYou're welcome.