Solved

change dbcurrency value after comparing tables

Posted on 2007-03-28
1
168 Views
Last Modified: 2010-04-05
I have a dbcurrency that gets data from a table (table1) in database.
I need to check this value against another table value (table2) after the table1 opens.
So when the table1 opens  if the table2 value is bigger than table1 I display a
message notifying user of the sum difference and ask to change the dbcurrency value to that of
table2 (i do not want to update table1 with new value just change the currencyedit value).


0
Comment
Question by:Vrtnar
1 Comment
 
LVL 26

Accepted Solution

by:
EddieShipman earned 125 total points
Comment Utility
Pardon me, but changing the value in the currencyedit will change the value in table1.

However, You would do this in the Table2.OnAfterOpen event.

procedure TForm1.Table2AfterOpen(DataSet: TDataSet);
begin
  // only do this check if Table1 is open
  if Table1.Active then
  begin
    if Table1.FieldByName('field1').AsCurrency < Table2.FieldByName('field1').AsCurrency then
    begin
      if (MessageDlg('Table2''s value is > Table1''s value, '+
                               'do you want to modify Table1''s Value?', mtConfirmation,
                               [mbYes, mbNo], 0) = mrYes) then
      begin
        Table1.Edit;
        Table1.FieldByName('field1').AsCurrency = Table2.FieldByName('field1').AsCurrency;
        Table1.Post;
      end;  
    end;
  end;
end;
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now