2
I have a Combobox that lists school units coming from my comic. Follow the code:
_fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) {
QueryUnidade->Close();
QueryUnidade->Open();
while (QueryUnidade->Eof == false){
ComboBoxUn->Items->Add(QueryUnidade->FieldByName("unidade")->AsString);
QueryUnidade->Next();
}
}
In my other combobox I need to list the Turns that are associated with the unit chosen in the first combobox, but it is not appearing. My code is like this:
void __fastcall TForm1::ComboBoxTurnoChange(TObject *Sender) {
QueryTurno->Close();
QueryTurno->ClearFields();
QueryTurno->SQL->Add("SELECT DISTINCT TURNO FROM ALUNO WHERE UNIDADE ='"+ (Trim(ComboBoxUn->Text)+"'"));
QueryTurno->Open();
while(QueryTurno->Eof == false){
ComboBoxTurno->Items->Add(QueryTurno->FieldByName("turno")->AsString);
QueryTurno->Next();
}
ComboBoxTurno->Update();
}