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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TDBCOMBOBOX

Status
Not open for further replies.

BrooksTech

Programmer
Nov 30, 2003
7
US
I am having an issue iwth my TDBCOMBOBOX in Delphi 7.

Although I have 13 items in my DB, The combobox is only showing that I have 1...when I click on the dropdown box, no other items appear. However, if I use a DBGrid, all of my items are listed within...but not in the combo or even in a listbox.

I know I am missing a step, but what is it?

Thanks in advance.
 
If I understand your question correctly, I think you should be using a TDBLookupComboBox instead of a TDBComboBox.

Andrew
 
I have tried, but the same results occur. When I try to define a "lookup," I get an error that says "Circular Defaults are not allowed."

Not real sure what to do at this point.
 
Are you trying to set the lookup table and the data table to the same value?

Brian
"There are 2 kinds of people in the world, those that divide people into two groups and those that don't. I belong to the second group." - tag line I stole
 
I need some sample code that shows how to populate a combobox from a database. In VB this was very sinple, but in Delphi I just cannot make it happen.
 
You need to add the items:

Code:
With Self.qryPPDates do
begin
  Active := True;
  While not eof do
  begin
    self.dbcPPDates.Items.Add(convertDate(FieldByName('APPDAT').AsString));
    next;
  end;
  First;
end;

Leslie
 
Thanks,

However, I'm tyring to use ADO and I'm not sure that code will help.
 
Are you using TADOTable or TADOQuery?

Brian
"There are 2 kinds of people in the world, those that divide people into two groups and those that don't. I belong to the second group." - tag line I stole
 
TADOTable I guess I should have noted taht before...sorry
 
Make sure that the lookup tables and data tables are active (ADOTable1.Open; or ADOTable1.Active := true;)

You will need a datasource pointing to the data table.

Set the DataSource of the wwdblookupcombo to your datatable datasource, and set the datafield property to the field you want to edit.

Set the LookupTable property of the wwdblookupcombo to the TADOTable that you want to use, and set the lookup field.

If you don't see the table when you try to set these properties, make sure that the unit that they are located in (datamodule?) is in your uses clause.

If you don't see the field name you're looking to set, right-click on the TADOTable and add fields. I think fields must be indexed to be used as a lookup.

If you want to do it in code, just set the properties at run-time:
DbLookupCombo1.DataSource := DataSource_Table1;

Hope this helps,
Brian

Brian
"There are 2 kinds of people in the world, those that divide people into two groups and those that don't. I belong to the second group." - tag line I stole
 
Even following your example to the letter, I still get the error "Circular Datalinks are not allowed."

I have:

Datasource with the Dataset linked to ADOTable1
ADOTable with the TableName Set to the "mytablename"
DBLookupComboBox with the datasource and the datafield proporties set. I also have the listsource, listfield and KeyField's set to the only options that show up in the dropdown box.

This produces the above listed error.
 
Sorry, I'm using Infopower components with slightly different properties than the ones in DBLookupComboBox.

I was able to get TDBLookupComboBox to work by setting the keyfield, and leaving list field empty. Does that work in your program?

Brian
"There are 2 kinds of people in the world, those that divide people into two groups and those that don't. I belong to the second group." - tag line I stole
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top