Primary Key value

From: George Kuascha (gkhokie_at_hotmail.com)
Date: 02/20/05


Date: Sun, 20 Feb 2005 11:14:24 -0500

I'm using D6 with MS Access2000. I'm copying field data from ADOTable2 to
ADOTable1 one record at a time. After each record is copied, I need to
capture the primary key (named ID) value in a variable (FindID). After
posting the record to ADOTable1, the primary key value returned in my code
is zero. I've also tried opening and closing the table between records and
that doesn't help. Can anyone enlighted me on what I'm missing here?

with ADOTable1 do
begin
   Insert;
   FieldByName('Name1').Value:= ADOTable2.FieldValues['Name1'];
.......
   Post;
end;
FindID:= ADOTable1.FieldByName('ID').AsInteger;
showmessage(inttostr(FindID));