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!

Getting a database field into a combobox and a listbox through ADO 1

Status
Not open for further replies.

PaidtheUmpire

Programmer
Jan 4, 2004
105
AU
Well please help...

I want to get the names of the teams for the ADOQuery1:
SELECT Team_Name
FROM Team_Details;

To the combobox called Team1.

Then once TEAM1 is set, the Listbox is to be populated by the playes of the said team though the ADOQuery2:
SELECT Name
FROM Players
WHERE Team_Name = :Team1;

Any help is rewarded with a thankyou in advance and afterwards as well.

Delphi I can't get enough of you.
 
You may create a stringlist, and then just assign the combobox items to the list.

You may also perform it manually thus:

begin
var k: integer;
//set to first record by useing open or first method of
//adoquery1
adoquery1.open;
adoquery2.open;
.
.
.
//add teams to combobox1 from adoquery1
adoquery1.first;
for k := 1 to adoquery1.recordcount do
begin
combobox1.items.add(adoquery1team_name.text);
adoquery1.next;
end;
//add team mates (players) to listbox1 from adoquery1
adoquery1.first;
for k := 1 to adoquery2.recordcount do
begin
listbox1.items.add(adoquery2name.text);
adoquery2.next;
end;


This is a rough idea. I'll run it later when I get home and send you a working code. Good luuck.
Yomi.

tomorrow I'll prepare the stringlist example for you.
Hope this helps.
 
You may create a stringlist, and then just assign the combobox items to the list.

You may also perform it manually thus:

begin
var k: integer;
//set to first record by useing open or first method of
//adoquery1
adoquery1.open;
adoquery2.open;
.
.
.
//add teams to combobox1 from adoquery1
adoquery1.first;
for k := 1 to adoquery1.recordcount do
begin
combobox1.items.add(adoquery1team_name.text);
adoquery1.next;
end;
//add team mates (players) to listbox1 from adoquery2
adoquery2.first;
for k := 1 to adoquery2.recordcount do
begin
listbox1.items.add(adoquery2name.text);
adoquery2.next;
end;


This is a rough idea. I'll run it later when I get home and send you a working code. Good luuck.
Yomi.

tomorrow I'll prepare the stringlist example for you.
Hope this helps.
 
Code should read something like this:
You may create a stringlist, and then just assign the combobox items to the list.

You may also perform it manually thus:

begin
var k: integer;
//set to first record by useing open or first method of
//adoquery1
adoquery1.open;
adoquery2.open;
.
.
.
//add teams to combobox1 from adoquery1
adoquery1.first;
for k := 1 to adoquery1.recordcount do
begin
combobox1.items.add(adoquery1team_name.text);
adoquery1.next;
end;
//add team mates (players) to listbox1 from adoquery2
adoquery2.first;
for k := 1 to adoquery2.recordcount do
begin
listbox1.items.add(adoquery2name.text);
adoquery2.next;
end;

 
Thanks for that...

Here is an added question related to the first is there a way to get the values selected in the ListBox to be placed in another ComboBox?

ie...
ComboBox 1 --> Select Team
ListBox -----> Select Players
ComboBox 2 --> Select Captain from Players Selected to Play

Delphi I can't get enough of you.
 
Yes there is. I don't fully understand your question so send your requirements and i'll assist you with the code (set you on the way).
yomi.
 
Thanks answered in another thread...

Delphi I can't get enough of you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top