Subject Re: IB_ComboBox as parameters
Author clatu_earth
Ok, sorry, only now I've realized it could be more verbose ;-)

The main query - IB_QueryOcorrencias:
-----------------------------------
select *
from LOG_OCORRENCIAS lo
join CAD_OCORRENCIAS co on lo.id_ocorrencia = co.id_ocorrencia
join cad_classe_ocorrencias cco on co.id_classe_ocorrencia =
cco.id_classe

The ComboBox query - IB_QueryClasseOcorrencia:
-----------------------------------
SELECT ID_CLASSE, DESCRICAO
FROM CAD_CLASSE_OCORRENCIAS

The code that loads the values and item values:
-----------------------------------------------
void __fastcall TFormCadInstalacoes::LoadCBoxClasseOcorrencia(void)
{
IB_CBClasseOcorrencia->Items->Clear();
IB_CBClasseOcorrencia->ItemValues->Clear();
IB_QueryClasseOcorrencia->Open();
while (!IB_QueryClasseOcorrencia->Eof) {
IB_CBClasseOcorrencia->Items->Add(IB_QueryClasseOcorrencia->FieldByName("DESCRICAO")->AsString);

IB_CBClasseOcorrencia->ItemValues->Add(IB_QueryClasseOcorrencia->FieldByName("ID_CLASSE")->AsString);
IB_QueryClasseOcorrencia->Next();
}
IB_QueryClasseOcorrencia->Close();
}



The event that adds the parameter:
-----------------------------------
void __fastcall
TFormCadInstalacoes::IB_QueryOcorrenciasPrepareSQL(TIB_Statement *Sender)
{
if (IB_CBClasseOcorrencia->ItemIndex != -1)
IB_QueryOcorrencias->SQLWhereItems->Add("id_classe_ocorrencia
= :id_classe_ocorrencia");
}


Propesties of the IB_ComboBox:
------------------------------
DataField = blank
DataSource= IB_DataSourceOcorrencias (which is connected to
IB_QueryOcorrencias)
ParamName = id_classe_ocorrencia

When the user select the tab where are the controls, the program runs
like this:

LoadCBoxClasseOcorrencia();
IB_QueryOcorrencias->InvalidateSQL();
IB_QueryOcorrencias->Active = true;

And nothing is showed in the Combo.
I hope not throwed out too much information this time. ;-)

Thanks.



--- In IBObjects@yahoogroups.com, Helen Borrie <helebor@...> wrote:
>
> At 12:58 AM 11/05/2006, you wrote:
>
> >Hi fellows!
> >
> >I'm trying to use IB_ComboBoxes as parameter entry for an IB_Query.
> >I've set the param_name property on the combo, set the datasource
> >accordingly and loaded the list, but the combo doesn't seem to work.
> >
> >It just appears empty when I run the program.
> >
> >What am I doing wrong?
>
> Cannot tell - you haven't given enough information about your setup.
>
> Specifics please:
>
> -- What is the SQL for the main query (that the combobox Datasource
points to)?
>
> -- What is the ParamName of the combobox set to?
>
> -- How and when do you load the Combobox Items?
>
> Helen
>