Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DBLOOKUPCOMBOBOX - ADDING NEW VALUE!

Status
Not open for further replies.

selena1

Programmer
Apr 7, 2003
69
Does anybody know how to enable that in DBLookupComboBox you can insert new value that don't exists in a list of values wich you get setting properties ListSource and ListField.
I have used DBComboBox component and next code:

while not Query1.Eof do
begin
DBComboBox1.Items.Add(Query1..FieldByName('State').AsString);
Query1.Next;
end;

Is there any better way?

THANKS!
 
DBLookupComboBox gets it look list from another dataset so to add another item to the list you must add another record to the lookup dataset.

The method you are suggesting is otherwise the best using out of the box Delphi.
 
The DBLookupComboBox is to ensure data consistency, that means that only valid entries are made. The data entered must be somewhere defined in a look-up table. The only way would be editing the look-up table and refreshing the listsource (query).

Check out: How to use Look Up fields with Tables /Queries faq102-1212 for a more concise explanation.

On the otherhand you should use a dbComboBox if you want the freedom of inserting new values.

Steven van Els
SAvanEls@cq-link.sr
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top