Strange behaviour of DbLookUpCombo [Urgent] lazarus / 16-Databases ---------------------------------------------------------------------- Paolo63Busto · 2011-06-11 07:57 Dear all, i'm a newbee in Lazarus, but i've had a quite long story on Delphi. i'm looking for an help about a strange behaviour of one DbLookUpComboBox: i've two forms, one work correctly and the other no, but are ( the second ) an exact copy ( cut&paste ) of the first one. both forms containing : an dbgrid showing a records in a table, some dbentryfields and dblookupcombobox for editing data, plus : 1 Mysql50connection n sqltransaction ( 1 for the dbgrid and entryfields and 1 for each lookupcombo) n sqlquery ( 1 for the dbgrid and entryfields and 1 for each lookupcombo) n Datasource ( 1 for the dbgrid and entryfields and 1 for each lookupcombo) in the first form when i select one different value from the dblookup, i see the cursor in the dbgrid changing and the value updated accordingly. in the second Form when i do the same action, the value remain unchanged and if the row previously selected on the grid was different from the first, the dbgrid seem to be resetted and the selected row return the first one. if i write chars on the dblookup the cursor on dbgrid change, but no one update take place. can anyone help me ..... all the autoedit properties are True ..... thanks in advance. P.S. the OS is Linux and the DB is MySql 5 Paolo i've changed to Zcomponents ...but with the same results .... HELP !!!! ---------------------------------------------------------------------- JD · 2011-06-18 16:58 Post a sample project to help us understand the problem better. ---------------------------------------------------------------------- Paolo63Busto · 2011-06-19 05:47 Thank you for your replay. For going ahead, i've changed my code moving the data access to another form ( that contains only ZConnections and ZQuerys ). Now the behaviour is changed a little bit. when i try to select a different value in one of the combos, the first time nothing appen, but the second time the value in the dbgrid change accordingly with what i've selected. But after the ApplyUpdate metod, if i try to close and reopen the query an error occurre in Close method ( of the query ). the error message is "invalid operation on an inactive dataset". in the attach file the 2 lfm involved. thanks in advance Paolo unit Componenti; {$mode objfpc}{$H+} interface uses   Classes, SysUtils, mysql50conn, sqldb, db, FileUtil, LResources, Forms,   Controls, Graphics, Dialogs, StdCtrls, DBGrids, DbCtrls, ZDataset,   ZConnection, BufDataset, Data ; type   { TComponentiForm }   TComponentiForm = class(TForm)     ButtonCompAdd: TButton;     ButtonCompDelete: TButton;     ButtonCompDiscard: TButton;     ButtonCompOk: TButton;     DBLookupListBox1: TDBLookupListBox;     EditLocalDS1: TDatasource;     ROLocalDS1: TDatasource;     ROLocalDS2: TDatasource;     DBEdit3: TDBEdit;     DBGrid1: TDBGrid;     DBLookupComboBox1: TDBLookupComboBox;     DBLookupComboBox2: TDBLookupComboBox;     Label1: TLabel;     Label3: TLabel;     Label4: TLabel;     ROLocalDS3: TDatasource;     procedure ButtonCompAddClick(Sender: TObject);     procedure ButtonCompDeleteClick(Sender: TObject);     procedure ButtonCompDiscardClick(Sender: TObject);     procedure ButtonCompOkClick(Sender: TObject);     procedure DBEdit3KeyPress(Sender: TObject; var Key: char);     procedure DBLookupComboBox1Select(Sender: TObject);     procedure FormActivate(Sender: TObject);     procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);     procedure FormCreate(Sender: TObject);   private     AddMode: Boolean;     FieldUpdated: Boolean;   public   end; var   ComponentiForm: TComponentiForm; implementation { TComponentiForm } procedure TComponentiForm.ButtonCompAddClick(Sender: TObject); begin      if (AddMode = True) or (FieldUpdated = True) then         begin              DataForm.EditQuery1.ApplyUpdates;         end;      DataForm.EditQuery1.Append;      AddMode := True;      FieldUpdated := False;      EditLocalDS1.DataSet.FieldValues['Ricette_id'] := DataForm.RicetteLink;      EditLocalDS1.DataSet.FieldValues['unita_misura_id'] := 0;      EditLocalDS1.DataSet.FieldValues['Gruppo_all_id'] := 0; end; procedure TComponentiForm.ButtonCompDeleteClick(Sender: TObject); begin      if (AddMode = True) or (FieldUpdated = True) then         begin              DataForm.EditQuery1.ApplyUpdates;         end;      DataForm.EditQuery1.Delete;      AddMode := True;      FieldUpdated := False; end; procedure TComponentiForm.ButtonCompDiscardClick(Sender: TObject); begin      DataForm.EditQuery1.CancelUpdates;      if (AddMode = False) and (FieldUpdated = False) then         begin              Close;         end;      AddMode := False;      FieldUpdated := False; end; procedure TComponentiForm.ButtonCompOkClick(Sender: TObject); begin      DataForm.EditQuery1.ApplyUpdates;      if (AddMode = False) and (FieldUpdated = False) then         begin              ComponentiForm.Close;         end         else             begin             DataForm.EditQuery1.Close;             DataForm.EditQuery1.Open;             end;      AddMode := False;      FieldUpdated := False; end; procedure TComponentiForm.DBEdit3KeyPress(Sender: TObject; var Key: char); begin      FieldUpdated := True; end; procedure TComponentiForm.DBLookupComboBox1Select(Sender: TObject); begin      FieldUpdated := True; end; procedure TComponentiForm.FormActivate(Sender: TObject); var SQLText: string; begin      if (DataForm.ActiveForm <> 'Componenti') then         begin              try                  DataForm.ActiveForm := 'Componenti';                  DataForm.ZConnection.Connected := False;                  DataForm.EditQuery1.Active := False;                  DataForm.EditQuery1.SQL.Text := 'select * from Componenti where Ricette_id =' + IntToStr(DataForm.RicetteLink) ;                  DataForm.EditQuery1.Active := True;                  DataForm.ZConnection.Connected := True;                  EditLocalDS1.DataSet := DataForm.EditQuery1;                  EditLocalDS1.Enabled := True;                  ROLocalDS1.Dataset.Active := True;                  ROLocalDS2.Dataset.Active := True;                  ROLocalDS3.Dataset.Active := True;                  ROLocalDS1.Enabled := True;                  ROLocalDS2.Enabled := True;                  ROLocalDS3.Enabled := True;              except                  on E: Exception do                  ShowMessage(E.message);              end;         end; end; procedure TComponentiForm.FormClose(Sender: TObject;   var CloseAction: TCloseAction); var tempstatus : boolean; begin     try        tempstatus:= EditLocalDS1.DataSet.Active;        DataForm.ZConnection.Connected := False;        DataForm.ActiveForm := '------';        EditLocalDS1.Enabled := False;        EditLocalDS1.DataSet := nil;        ROLocalDS1.Dataset.Active := False;        ROLocalDS2.Dataset.Active := False;        ROLocalDS3.Dataset.Active := False;        ROLocalDS1.Enabled := False;        ROLocalDS2.Enabled := False;        ROLocalDS3.Enabled := False;   except     on E: Exception do       ShowMessage(E.message);   end; end; procedure TComponentiForm.FormCreate(Sender: TObject); begin     AddMode := False;     FieldUpdated:= False; end; initialization   {$I componenti.lrs} end.