When used with the KADao components, DBLookupComboBox's work fine - they display all related records.
However, when using the Interbase controls with Firebird, only the first record of the lookup table (or related query) is shown. Once you scroll through the possible values, then the list displays with multiple values as expected.
Firebird Related Fixes
Assuming that DBLookupComboBox2 is connected to Query_DataSource.ListSource, simply moving to the last record fixes the problem.
procedure TForm1.DBLookupComboBox2DropDown(Sender: TObject); begin Query_DataSource.DataSet.Last; end; IBDatabase1 -> IBQuery1 -> Query_DataSourceWithout this fix, when IBQuery1.SQL is
select "User_ID" from "Group_User_Map_tbl" where "Group_ID" = 'Uad_1'the drop down list shows all the records, but when IBQuery1.SQL is
select "User_ID" from "Group_User_Map_tbl"only one record is shown.
An alternate approach is
procedure TForm1.DBLookupComboBox2DropDown(Sender: TObject); begin Query_DataSource.DataSet.FetchAll; end;
Multiple DBLookupComboBoxes
This is a real pain.
This is one work around ... but it uses regular ComboBoxes ... not DBLookupComboBoxes.
procedure TAdd_Port_Form.Init_Picklists; var flag : boolean; s : string ; i : integer; ds : TDataset; procedure Load_ComboBox(Filter:string; CB: TComboBox); var i : integer; begin CB.Items.Clear; ds.Filter := '"Barcode_Type_ID" = ''' + Filter + ''''; ds.Filtered := true; ds.First; flag := ds.Bof; if flag then begin s := ds.FieldByName('Barcode').AsString; CB.Items.Add(s); ds.Next; while not ds.eof do begin s := ds.FieldByName('Barcode').AsString; CB.Items.Add(s); ds.Next; end; end; end; begin ds := SamplesDataModule.Barcodes_DataSource.DataSet; Load_ComboBox('Exp', Port_UIComboBox ); // Exposure Location Load_ComboBox('F_Hld', Filter_UIComboBox); // Filter Holder Load_ComboBox('S_Hld', Sample_UIComboBox); // Sample Holder end;Notice that for the IB components, FindFirst and FindNext are not implemented (they always return false).
Another solution is to provide a separate query object per lookup component.
Updating DBLookupComboBox's with new data
Simple plan
The solution is fairly simple
f := IBTable_Batches.Locate ('Batch_Name', v , [loCaseInsensitive]); if f then begin result := 'Duplicate'; exit; // error end; s := 'INSERT into "Batches_tbl" (' + '"Batch_Name", "Description")' + ' Values (''' + Name + ''', ''' + Description + '''' + ') ' ; // Contents of ExecuteSQL(s) procedure - shown inline for readability IBQuery1.SQL.Text := s; IBQuery1.ExecSQL; IBQuery1.SQL.Text := 'commit'; // This allows other programs to see changes IBQuery1.ExecSQL; // end of ExecuteSQL IBTable_Batches.Close; // Required to see the new record IBTable_Batches.Open; // but won't work if the transaction is sharedActually, Locate should not be used for this purpose because it potentially copies all the records from the server to the client. It is definitely better to execute a query and see if any rows are returned.
DBCtrlGrid