Subject Re: [IBO] How to Format a FLOAT field?
Author Helen Borrie
At 06:39 PM 24/02/2005 +0000, you wrote:

>Hi All!
>I want to format a float field with 2 decimals, ex.: 12.2156523123,
>converted = 12.21. I tried to use
>IB_Connection.FieldsDisplayFormat := 'TEST=0.00' and
>IB_Connection.FieldEntryTypes = fetDomainName, but it gives me this
>error: "EConvertError with message "xxxx" is not a valid integer

At connection level, you have to specify either domain (with fetDomainName
included in FieldEntryTypes) or fully-qualified column identifier (with
fetSQLType included). In code, the FieldEntryTypes property should be set
*first*, before your code tries to access FieldsDisplayFormat. The format
string has to be a valid Delphi format string.

It is much easier to set these properties at design time. For example,
set FieldEntryTypes to [fetSQLType,fetDomainName]
and set FieldsDisplayFormat to



The simplest thing to do is just to set the CURRENCY property of the domain
or column to True. You only need a format string if you want to include
extra things (like a currency symbol, for example).

-- With an IB_Query, do this in the Fields Editor (Column Attributes)
-- With any IB_Dataset or IBODataset, you can set it in the
ColumnAttributes property (a stringlist) or in code
-- If you have a domain for your currency fields, you can set this property
for all fields in the database, by including fetDomainName in the
FieldEntryTypes set of your connection object. If you want to set it
globally at field level, then also include fetSQLType.

At connection level, open the editor for ColumnAttributes. To specify the
Currency attribute for a domain named D_Money, do this:


To specify it globally at field level, e.g. for a table named Invoice with
a column named Total:


To specify it at dataset level (for ib_cursor and ibodatasets), open the
ColumnAttributes editor and enter


There is a TI Sheet on all of this: Working with Fields and Params
(download from the Tech Info page of the IBO website). If you have the
Getting Started Guide, there is an Appendix on the topic.

If you are using the TIBODatasets ("TDataset-compatible") you also have the
option of instantiating a TField and making it a TIBOBCDField.