Problem with Locate
I am having a problem with the Locate command. Following is code that
does not work and what I am trying to do.
I have a DBEdit11 asigned to the field PER_ID which is an Integer
field. When a value is entered or changed. I need to check and see if
that value already exist in another record, same dataset , as the same
ID number is not valid for two records. I simply need to see if it
already exist. Not make the results the current record, or at lease
return to the current record. I have used Locate many times and haven't
had this problem before. While I have the procedure in the "Before Post
Event" there are any number of other places it can be put.
********************Start Code
procedure TBurialForm.HCemeteryBeforePost(DataSet: TDataSet);
var
IDLookUp: Boolean;
begin
// The following line causes a stack overflow.
IDLookUp:=HCemetery.Locate('PER_ID',
HCemetery.FieldByName('PER_ID').AsInteger,[]);
if IDLookUp Then
begin
PlaySound(PChar('ERROR'), hInstance, snd_ASync or snd_Resource);
ShowMessage('WARNING!!! --> The Personal ID You Entered ia
already in use.'+#13+#10+'Two Persons cannot have the same ID Number.
Enter another ID Number.');
DBEdit11.SetFocus;
end;
end;
******************End Code
Using D4 (patch 3), Halcyon, Clipper Function for Delphi, DBF/NTX
Thanks for any help you can give.
Tom Waldie
Design Software
Comprehensive Software for Genealogy Data Management