Solved

comparing records in a database

Posted on 1998-10-01
1
233 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying 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

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…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

831 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