DXE5 for a TIBQuery I build a sql at run time , so I have not persistent fields.
For each record I retrieve some values I want to format with the corresponding decimal scale stored in same record.
Which way can I do it ? which TIBQuery property I need work with and how ?
Regards
Adalberto Baldini
Adalberto Baldini wrote:
> Thank it works well.
> As I may use the query many times, always building a new SelectSQL and varying the numeber of fields, do I need to clear some memory between a Dataset.Close and new Open?
> Regards Adalberto
No non persistent fields are cleared whenever the query is unprepared and that
happens whenever you change the SelectSQL. New Fields will be created when the
new query is opened which is why you have to re establish OnGetText or
DisplayFormat properties after opening because it is a new TField.
--
Jeff Overcash (TeamB)
(Please do not email me directly unless asked. Thank You)
And so I patrol in the valley of the shadow of the tricolor
I must fear evil. For I am but mortal and mortals can only die.
Asking questions, pleading answers from the nameless
faceless watchers that stalk the carpeted corridors of Whitehall.
(Fish)
Thank it works well.
As I may use the query many times, always building a new SelectSQL and varying the numeber of fields, do I need to clear some memory between a Dataset.Close and new Open?
Regards Adalberto
Adalberto Baldini wrote:
> This works, and I put it in afterscroll event of dataset, but when I change record new format is applied to all records of dataset. I need to format every record with its own format.
> In an app with persistent field I used
>
> procedure TDtMd_RegCoge_Frames.IBQry_SdiValDSPSALDOGetText(Sender: TField;
> var Text: string; DisplayText: Boolean);
> begin
> Text := FormatFloat(fmt[Sender.DataSet.FieldByName('decimal_scale').asinteger
> + 1],Sender.asFloat) ;
> DisplayText := True;
> end;
>
> How could I get same result in a dataset with no persistent fields ?
>
> Adalberto Baldini
Create your event like normal then in the after open (when the fields are now
created when not persisted do
aDataSet.FieldByName().OnGetText := IBQry_SdiValDSPSALDOGetText;
--
Jeff Overcash (TeamB)
(Please do not email me directly unless asked. Thank You)
And so I patrol in the valley of the shadow of the tricolor
I must fear evil. For I am but mortal and mortals can only die.
Asking questions, pleading answers from the nameless
faceless watchers that stalk the carpeted corridors of Whitehall.
(Fish)
This works, and I put it in afterscroll event of dataset, but when I change record new format is applied to all records of dataset. I need to format every record with its own format.
In an app with persistent field I used
procedure TDtMd_RegCoge_Frames.IBQry_SdiValDSPSALDOGetText(Sender: TField;
var Text: string; DisplayText: Boolean);
begin
Text := FormatFloat(fmt[Sender.DataSet.FieldByName('decimal_scale').asinteger
+ 1],Sender.asFloat) ;
DisplayText := True;
end;
How could I get same result in a dataset with no persistent fields ?
Adalberto Baldini
Adalberto Baldini wrote:
>> Just call FieldByName to get the TField then set the Display property just like
>> you would if you persist it at design time.
>>
>
> I tried :
>
> IBDts_Wk_Bilancio.FieldByName(Fil_Field_List[i]).FieldName.Format := fmt[dec_scl+1];
>
> but it seems something is wrong, and
> IBDts_Wk_Bilancio.FieldByName(Fil_Field_List[i]). has not a displayformat property
>
> Adalberto
DisplayFormat for number types is introduced at the TNumericField level so you
have to typecast the TField to TNumericField before setting the DisplayFormat.
The AfterOpen event is a good place to be setting all these things.
TNumericField(IBDts_Wk_Bilancio.FieldByName(Fil_Field_List[i])).Displayformat :=
fmt[dec_scl+1];
--
Jeff Overcash (TeamB)
(Please do not email me directly unless asked. Thank You)
And so I patrol in the valley of the shadow of the tricolor
I must fear evil. For I am but mortal and mortals can only die.
Asking questions, pleading answers from the nameless
faceless watchers that stalk the carpeted corridors of Whitehall.
(Fish)
> Just call FieldByName to get the TField then set the Display property just like
> you would if you persist it at design time.
>
I tried :
IBDts_Wk_Bilancio.FieldByName(Fil_Field_List[i]).FieldName.Format := fmt[dec_scl+1];
but it seems something is wrong, and
IBDts_Wk_Bilancio.FieldByName(Fil_Field_List[i]). has not a displayformat property
Adalberto
Adalberto Baldini wrote:
> DXE5 for a TIBQuery I build a sql at run time , so I have not persistent fields.
> For each record I retrieve some values I want to format with the corresponding decimal scale stored in same record.
>
> Which way can I do it ? which TIBQuery property I need work with and how ?
>
> Regards
> Adalberto Baldini
Just call FieldByName to get the TField then set the Display property just like
you would if you persist it at design time.
FYI, TIBDataset is more efficient than TIBQuery. TIBQuery should only really be
used if you are migrating a BDE app, otherwise there is no reason to use it.
--
Jeff Overcash (TeamB)
(Please do not email me directly unless asked. Thank You)
And so I patrol in the valley of the shadow of the tricolor
I must fear evil. For I am but mortal and mortals can only die.
Asking questions, pleading answers from the nameless
faceless watchers that stalk the carpeted corridors of Whitehall.
(Fish)