Databases - Delphi - DBLookupComboBox

The DBLookupComboBox provides a simple way to associate a long descriptive name (stored in a lookup table) with a short (or numeric) key.

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 | Multiple DBLookupComboBox's | Displaying new data | DBCtrlGrid


Firebird Related Fixes

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.

Assuming that DBLookupComboBox2 is connected to Query_DataSource.ListSource, simply moving to the last record fixes the problem.

Without this fix, when IBQuery1.SQL is the drop down list shows all the records, but when IBQuery1.SQL is only one record is shown.

An alternate approach is


Multiple DBLookupComboBoxes

Using KADao components, a single DataSource can be used with several DBLookupComboBox's ... each showing a different subset of the data by setting the filter when the list is displayed. However, with IB Components, redefining the query (or filter) changes the values for all associated DBLookupComboBoxes.

This is a real pain.

This is one work around ... but it uses regular ComboBoxes ... not DBLookupComboBoxes.

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

This is another area with no documentation.

Simple plan

The main problem was that IBTable_Batches.Locate would not detect changes made to the table.

The solution is fairly simple

This code works Actually, 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

Give me a break, the DBLookupComboBox does not work in a DBCtrlGrid. (Actually, many components don't work in DBCtrlGrid's, but you would think that the DB components would.)

Here are a few work arounds


Author: Robert Clemenzi - clemenzi@cpcug.org
URL: http:// cpcug.org / user / clemenzi / technical / Databases / Delphi / DBLookupComboBox.html