Solved

comparing records in a database

Posted on 1998-10-01
1
230 Views
Last Modified: 2010-04-06
Before i start thanks to the person who kindly assisted me with my last question.

I am trying to write a procedure that uses findkey to locate a record that part is ok, i then need to however compare the fields with the last record i went to and if there is a difference perform another procedure.

I am able to use findkey and assign the fields i need to compare to variables.  However i need to be able to compare these variables to the last record i did findkey on.

procedure Tproductionfrm.M1Pending; {checks for pending jobs in schedule}
var
  IsColorChange: Boolean;
  IsEndOfRun: Boolean;
  ColorToTest: String;
  ProductToTest: String;
begin
  IsColorChange:= False;
  IsEndOfRun:= False;
  with scheduler.SchT do
     begin
        Open;
        Edit;
        First;
           if FindKey(['Machine 1', 'P']) then {Pending}
           begin
              ProductToTest:=scheduler.SchT.Fields[3].AsString; {product for selected record}
              ColorToTest:=scheduler.SchT.Fields[4].AsString; {colour for selected record}
           end;

     end;
end;

This is the basics at the moment and i have yet to perform any comparison.

any clues?
0
Comment
Question by:npepper
1 Comment
 

Accepted Solution

by:
chrismo earned 100 total points
ID: 1341419
I would say set up two additional variables that store the previous value:

var
  LastProductToTest: string;
  LastColorToTest: string;
begin
  ProductToTest := ...
  ColorToTest := ...

  if (ProductToTest <> LastProductToTest)
     or
     (ColorToTest <> LastColorToTest) then
    DoOtherMethod;

  LastProductToTest := ProductToTest;
  LastColorToTest := ColorToTest;
end;

0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

743 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

12 Experts available now in Live!

Get 1:1 Help Now