Board index » delphi » Locate Exception when Record not found.

Locate Exception when Record not found.

I have the following procedure that gives me an exception when the
Locate function fails to find a record. Actually it gives an exception
with the message 'Record Not Found' sometimes and displays the
showmessage dialog other times. I can't figure out what the difference
is. This is an Access database. Anyone have any idea what is going on
- I would greatly appreciate the help.

var
 vMemberid : Integer;
 vName :String;
begin
  inherited;
 With DBGrid1.DataSource.DataSet do
  begin
   vmemberid := fieldByName('Memberid').Asinteger;
   vName := FieldByName('Name').AsString;
  end;
 With DBGrid2.DataSource.DataSet do
  If not Locate('Memberid',vmemberid,[]) then <<<< Exception here
    ShowMessage(vName + ' not in List');
end;

Ross Williams
Advocacy Technologies

My actual email address is:
rossw...@spiritzero.com
the "zero" in "spiritzero.com" should be replaced by "one"

 

Re:Locate Exception when Record not found.


I have the following procedure that gives me an exception when the
Locate function fails to find a record. Actually it gives an exception
with the message 'Record Not Found' sometimes and displays the
showmessage dialog other times. I can't figure out what the difference
is. This is an Access database. Anyone have any idea what is going on
- I would greatly appreciate the help.

var
 vMemberid : Integer;
 vName :String;
begin
  inherited;
 With DBGrid1.DataSource.DataSet do
  begin
   vmemberid := fieldByName('Memberid').Asinteger;
   vName := FieldByName('Name').AsString;
  end;
 With DBGrid2.DataSource.DataSet do
  If not Locate('Memberid',vmemberid,[]) then <<<< Exception here
    ShowMessage(vName + ' not in List');
end;

Ross C. Williams
Advocacy Technologies

My actual email address is:
rossw...@spiritzero.com
the "zero" in "spiritzero.com" should be replaced by "one"

Other Threads