Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 8 of 8 total
Thread Confused with editing currency values
Wed, Oct 15 2014 5:13 PMPermanent Link

Jeff Cook

Aspect Systems Ltd

Avatar

Hi

I'm having a problem with what seems to be an elementary thing.

I'm (slowly) converting a DBISAM v3, Delphi 7 app to ElevateDB v2.17b2,
Delphi XE.

In DBISAM3
----------

My currency values were defined in the database a "MONEY" fields and as
TCurrencyField in Delphi.

When displayed in a TDBEdit they were formatted like this "$1,234.56"
and when you clicked on the field in edit mode they changed to "1234.56"

In EDB
------

My currency values are defined in the database a "DECIMAL(1`9,2)" fields
and as TBCDField in Delphi.

When displayed in a TDBEdit they are formatted like this "1,234.56" and
when you clicked on the field in edit mode they DO NOT change.

Consequently, if you change the amount in the TDBEdit to (say) 1,234.00
you get an error:-
---------------------------------------------------------------------------
'1,234.00' is not a valid floating point value for field 'RentAmount'.
---------------------------------------------------------------------------

I can see the problem is the comma and is you manually remove the comma
in the TDBEdit, then the problem does not appear - but I obviously can't
expect users to do that!

I feel and fervently hope that there something minor wrong that I'm just
not seeing.  It is a big app with 240 forms and many, many  currency
values in TDBEdits

TIA

Jeff
Thu, Oct 16 2014 4:45 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Jeff


I've just done a quick try here (ansi 2.17b1 & d2006) and I get what I'd expect in both a TDBEdit & TDBGrid 2333.33 ie no comma, no formatting.

I just quick built an "app" to show data from one table. The field I dumped into the dbedit was DECIMAL(19,2) in ElevateDB and TBCDField in Delphi.

Do you have any OnGetText, OnSetText events defined, or any DisplayFormat / EditFormat set as part of the field in Delphi?

Roy Lambert
Thu, Oct 16 2014 5:13 AMPermanent Link

Uli Becker

Jeff,

in addition to what Roy said:

the only way for me to get the result you described, is to change the
"EditFormat" property of the TBCDField. Maybe you entered something
there instead of using "DisplayFormat".

Anyway it would be sufficient to set the propert "Currency" = true.

Hope that helps

Uli
Thu, Oct 16 2014 5:31 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Uli

>Anyway it would be sufficient to set the propert "Currency" = true.

That's brilliant! Using Delphi from v1 and I never knew that. I can use it myself.

Roy Lambert
Thu, Oct 16 2014 5:48 AMPermanent Link

Uli Becker

Roy,

> That's brilliant! Using Delphi from v1 and I never knew that. I can use it myself.

Smile

Uli
Thu, Oct 16 2014 5:13 PMPermanent Link

Jeff Cook

Aspect Systems Ltd

Avatar

On 16/10/2014 10:48 p.m., Uli Becker wrote:
> Roy,
>
>> That's brilliant! Using Delphi from v1 and I never knew that. I can
>> use it myself.
>
> Smile
>
> Uli
>

Thanks Uli and Roy

Now that I know the answer it is blindingly obvious!

GExperts tells me that I have 1462 occurrences or TBCDField in 182 files!

And blow me down, each has DisplayFormat = ',0.00' - I should have seen
that.

These tables have come from Paradox via DBISAM v2 and v3 and now to
ElevateDB in a 15 year journey.  You would Have thought that I'd know
about this before now Wink

OK, so I'll just do a system wide Find/Replace and convert all the
DisplayFormat's to currency = True and, Bob's your Auntie, all shall be
well!

Cheers

Jeff
Fri, Oct 17 2014 4:33 AMPermanent Link

Uli Becker

Jeff,

I have to correct myself:

Also "DisplayFormat" formats the field's value in edit-mode, not only
"EditFormat".
So setting "DisplayFormat" = null and "Currency" = true will do it.

Uli
Fri, Oct 17 2014 7:58 PMPermanent Link

Jeff Cook

Aspect Systems Ltd

Avatar

On 17/10/2014 9:33 p.m., Uli Becker wrote:
> Jeff,
>
> I have to correct myself:
>
> Also "DisplayFormat" formats the field's value in edit-mode, not only
> "EditFormat".
> So setting "DisplayFormat" = null and "Currency" = true will do it.
>
> Uli

Thanks Uli

I used GEXperts to change all occurrences of DisplayFormat ... to
currency = True and, as far as I can see, normal service has been
resumed Wink

Cheers

Jeff
Image