Toolbar focus lazarus / 31-LCL ---------------------------------------------------------------------- mangakissa · 2014-03-18 21:48 I want to be sure that al my fields has the new value from a DBEdit. If fill in the last DBEdit and save my data with a button on my toolbar. Before I save my data, I check if my required fields on empty. If all the required fields are filled, but the last required DBEdit still has the focus, my function tells the field is empty, because TDBEdit.field.newvalue doesn't have the filled in data. So before saving all data, I set Toolbar1.setfocus.  The DBEdit will be leaved and the OnExit event in TDBEdit will be triggered and TDBEdit.field.newvalue got a value. But when I want to set Toolbar1.setfocus, my application shows a dialog (see attachment). Who shows this dialog when debugger is set off? Why can't I give a TToolbar a focus? It's working in Delphi. ---------------------------------------------------------------------- wp · 2014-03-18 23:59 Why don't you work with the BeforePost event of the dataset? This is called automatically before the record is saved. ---------------------------------------------------------------------- mangakissa · 2014-03-19 08:09 That doesn't solve why I can't set TToolbar.setfocus. ---------------------------------------------------------------------- wp · 2014-03-19 09:00 No, you can't, that's by design. Because toolbuttons can't get the focus - you cannot use the arrow keys to navigate between the toolbuttons, even not in Delphi. I think the behavior of Delphi of accepting the focus for TToolbar is misleading. If you really want to bring the focus to the toolbar you have to add something like a TEdit to the toolbar; set its width to zero to keep it "alive", don't use Visible=false. But I think this is poor design of your app. My question is again: Why don't you use the events provided by the dataset to handle error checking? This is called no matter how you save changes: by a save button, by a TDBNavigator, by activating another record... Code: [Select]procedure TMainForm.Dataset1BeforePost(Dataset: TDataset); begin   if Dataset.FieldByName('Date').IsNull then begin     MessageDlg('Non-empty input required here', mtError, [mbOK], 0);     Abort;   end end;