Problem: Change Currency to Euro? 
Author Message
 Problem: Change Currency to Euro?

Hi there,

I have a Paradox-table with an currency-field which will
be shown in a DBGrid (Normal grid or the grid from the
RXLibrary) and a DropDownList on a formular. With the
DropDownList the user can chose between two different
currencies (DM and Euro).

How can I change the currency shown in the grid (e.g. from
DM to Euro) while the grid is displayed if the user choses a
new currency from the DropDownList? The money-amount
must also be translated into the other curreny (e.g. from
100 DM to 50 Euro)!



Fri, 04 May 2001 03:00:00 GMT  
 Problem: Change Currency to Euro?
You don't indicate if you have a single amount field, of if you have
separate Euro and a DM fields.

First case, you can loop thru the query and recompute.

query.first
while not query.eof do
  query.edit;
  recompute field;
  query.post;
  query.next;
end;

If you already have both amounts calculated as separate fields in your
database, you might try changing the field hooked up to the dbgrid column to
display the required amount. Look up the details on columns help on the
DBGrid ('ve neve had to do that, but should work).

Remember, you can change the formatting and the column heading of a field at
run time.

Hope this helps.

Robert

Quote:

>Hi there,

>I have a Paradox-table with an currency-field which will
>be shown in a DBGrid (Normal grid or the grid from the
>RXLibrary) and a DropDownList on a formular. With the
>DropDownList the user can chose between two different
>currencies (DM and Euro).

>How can I change the currency shown in the grid (e.g. from
>DM to Euro) while the grid is displayed if the user choses a
>new currency from the DropDownList? The money-amount
>must also be translated into the other curreny (e.g. from
>100 DM to 50 Euro)!



Sat, 05 May 2001 03:00:00 GMT  
 Problem: Change Currency to Euro?
Thank you Robert for your tip, but it doesn't fit my problem:

I have a curreny field (with DM amount) in my database an no field for Euro.
I don't want to change the database, I only want a changing of the OUTPUT
from this field in the grid.

I already thought about redrawing the grid by my program to solve the problem,
but I couldn't figure out how, yet.



Sun, 06 May 2001 03:00:00 GMT  
 Problem: Change Currency to Euro?
I may be that I don't understand your question, but the solution seems
pretty simple to me (especially now that Dianne gave me a solution on how to
create a temporary field)

Query:

SELECT SOMEFIELD, SOMEOTHER, DM, CAST(0 AS DECIMAL(13,2)) AS AMOUNTTODISPLAY
FROM TABLE;

Then in your program:

EuroDisplay : Boolean;  (in private section)

Form Initialize
Query.Open;
ComputeDisplayCurrency(1.0);
EuroDisplay := False;
EuroOrDMButton.Caption := 'Euro';

Procedure ComputeDisplaycurrency(factor : double);
begin
  with query do
   begin
     first;
     while not eof do
       edit;
       fieldbyname('amounttodisplay').value := fieldbyname('dm').value *
factor;
       post;
       next;
    end;

OnClick the button
if eurodisplay then
  begin
    ComputeDisplayCurrency(1.00);
    eurodisplay := false;
    button.caption := 'Euro';
  end else
    ComputeDisplayCurrency(factor);
     eourodisplay := true;
     button.caption := 'DM';
  end;

Quote:

>Thank you Robert for your tip, but it doesn't fit my problem:

>I have a curreny field (with DM amount) in my database an no field for
Euro.
>I don't want to change the database, I only want a changing of the OUTPUT
>from this field in the grid.

>I already thought about redrawing the grid by my program to solve the
problem,
>but I couldn't figure out how, yet.



Wed, 09 May 2001 03:00:00 GMT  
 Problem: Change Currency to Euro?
I may be that I don't understand your question, but the solution seems
pretty simple to me (especially now that Dianne gave me a solution on how to
create a temporary field)

My solution uses a button, where the caption changes form Euro to DM, and
changes the whole table, but a similar approach should work if you just want
to change one row (you do the conversion in the before post event)

Remember that you control which fields in the query get displayed in the
grid.

Query:

SELECT SOMEFIELD, SOMEOTHER, DM, CAST(0 AS DECIMAL(13,2)) AS AMOUNTTODISPLAY
FROM TABLE;

Then in your program:

EuroDisplay : Boolean;  (in private section)

Form Initialize
Query.Open;
ComputeDisplayCurrency(1.0);
EuroDisplay := False;
EuroOrDMButton.Caption := 'Euro';

Procedure ComputeDisplaycurrency(factor : double);
begin
  with query do
   begin
     disablecontrols;
     first;
     while not eof do
       edit;
       fieldbyname('amounttodisplay').value := fieldbyname('dm').value *
factor;
       post;
       next;
    end;
    enablecontrols;

OnClick the button
if eurodisplay then
  begin
    ComputeDisplayCurrency(1.00);
    eurodisplay := false;
    button.caption := 'Euro';
  end else
    ComputeDisplayCurrency(factor);
     eourodisplay := true;
     button.caption := 'DM';
  end;

Quote:

>Thank you Robert for your tip, but it doesn't fit my problem:

>I have a curreny field (with DM amount) in my database an no field for
Euro.
>I don't want to change the database, I only want a changing of the OUTPUT
>from this field in the grid.

>I already thought about redrawing the grid by my program to solve the
problem,
>but I couldn't figure out how, yet.



Wed, 09 May 2001 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. EURO, Dual currency problems

2. Euro currency symbol ...

3. Euro currency symbol ...

4. problem with Access Currency Field

5. Currency format problem

6. Currency Problems

7. Currency Problem with Delphi

8. AddFieldDef - (currency) Decimal point problem

9. Euro models wants to come to USA , Canada

10. Euro-character on epson

11. Printing the Euro character ...

12. Urgent: Euro sign in TurboPascal

 

 
Powered by phpBB® Forum Software