Hey,
I've been busy coding combo boxes to filter a database but the problem is they don't work together. e.g. If i select a car type, it shows all the cars of that type but if i select blue in one combo box and a car type in the other one: It doesn't filter for blue cars of that type, it just filters for the latest one selected.
I'm fairly new to Delphi so i don't have a massive technical knowledge yet so I have no idea how to get them to work together? Any ideas?
My code looks something like this:
procedure TForm1.FormActivate(Sender: TObject);
begin
ADOQuery1.Active := false;
ADOQuery1.sql.Text := 'select * from [car list] ' ;
ADOQuery1.Active := true;
ADOTable1.Open;
ADOTable1.First;
while not ADOTable1.Eof do
begin
cmbtype.Items.add(ADOTable1['car type']);
cmbcolour.Items.add(ADOTable1['car colour']);
ADOTable1.Next;
end;
end;
procedure TForm1.cmbtypeChange(Sender: TObject);
begin
ADOQuery1.Active := false;
ADOQuery1.sql.Text := 'select * from [car list] where [car type] = "'+ cmbtype.Text+'"';
ADOQuery1.Active := true;
end;
procedure TForm1.cmbcolourChange(Sender: TObject);
begin
ADOQuery1.Active := false;
ADOQuery1.sql.Text := 'select * from [car list] where [car colour] = "'+ cmbcolour.Text+'"';
ADOQuery1.Active := true;
end;
end.