Subject Re: [IBO] How to add Tfields persisntents with a TIBOquery in run-time?
Author Delmar Wichnieski
> > I can't get sucessful trying to add persistents fields in run-time (not
with fields editor).
> > I'm tried this code:
> >
> > MyIBOquery.FieldDefs.Add('CODIGO',FTinteger,0,true);
> >
> > but in subsequent lines like this :
> >
nprincipal.Memo1.Lines.Add(QrecepcaoAvisosPCconcluidoCODIGO.AsString);
> > message error: Access violation at address 005F0983 in module
myproject.exe
> >
> > in this:
> >
qrecepcaoAvisosPCconcluido.FieldByName('CODIGO').OnGetText:=QrecepcaoAvisosP
CconcluidoCODIGOgettext;
> >
> > Project projeto.exe raise exception class EDatabaseError with message
'field 'CODIGO' not found'.
> >
> > Any comment will be very appreciated.
>
> Your variable names are *far* too long. ;-)
>
> But anyways, why don't you use a calculated field?
> Simply do
>
> YourQuery.CaluclatedFields.Add( "CODIGO Integer" );
>
> And in OnCalculateField (of YourQuery):
>
> if( AField.FieldName = "CODIGO" ) then
> {
> Assign your data, e.g. AField.AsString := "Test";
> }
>
> regards,
> Daniel Albuschat

YourQuery.CaluclatedFields.Add( "CODIGO Integer" );

My Delphi IDE don't display YourQuery.CaluclatedFields.xxxxxx. why?
My ibo version is 4.2.Ie.

CaluclatedFields is new in more recent versions?

In relation to "Your variable names are *far* too long" I reduce the name.
Now
QpcPronto.FieldDefs.Add('CODIGO', FTinteger,0,true);
but problem persist at QpcProntoCODIGO.OnGetText:=QpcProntoCODIGOgettext;

?????