Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

change dbcurrency value after comparing tables

Posted on 2007-03-28
1
Medium Priority
?
175 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 26

Accepted Solution

by:
EddieShipman earned 500 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

670 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