Solved

change dbcurrency value after comparing tables

Posted on 2007-03-28
1
169 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
ID: 18818977
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

911 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

20 Experts available now in Live!

Get 1:1 Help Now