[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 239
  • Last Modified:

calculate dbcurrencyedits

I am having problems calculating witd dbcurrency edit.
Example:
procedure TPostavke.Edit51Change(Sender: TObject);
var a: Currency;
 b: integer;
begin
if TryStrToCurr(currencyedit37.Text,a) and TryStrToInt(edit51.text,b) then
edtCurr11.value:= a * b ;
end;

This works but if I replace currencyedit37 with a dbcurrencyedit it will not work and it beats me why not.
To go over this how can I display a value of a currency field from a database in currencyedit
depending on the row i click in the grid (contact I select in grid)?Can you tell me alsohow  to calculate 2 dbcurrencyedits?
0
Vrtnar
Asked:
Vrtnar
  • 2
1 Solution
 
LimbeckCommented:
im not completely following you but here goes.

first of all you should use dbedit instead of edit. Connect the dbedit to the same datasource as your dbgrid.

instead of using the onchange use a calculated field and use that as a datafield of the dbedit you want to show the result in.

search your help files "calculated field"  for details.

good luck
Ed
0
 
VrtnarAuthor Commented:
that is too much work ...
I'd like to calculate 'on the fly' ...
0
 
LimbeckCommented:
then try something like

if (not yourdbcurrencyedit.Field.isNull) and TryStrToInt(edit51.text,b) then
edtCurr11.value:=yourdbcurrencyedit.Field.AsCurrency*b
0
 
Computer101Commented:
Forced accept.

Computer101
EE Admin
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now