I have a Combobox that lists school units coming from my DB. Here is 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 shifts that are associated with the drive chosen in the first combobox, but it is not appearing. My code looks 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();
}