Solved

change dbcurrency value after comparing tables

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

810 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