Solved

change dbcurrency value after comparing tables

Posted on 2007-03-28
1
171 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

830 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