Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem with autonum?

Status
Not open for further replies.

jbpelletier

Programmer
Sep 8, 2001
232
0
0
CA
using d5 with an acces database...

the key of my table is an autonum (access)

problem:
when im inserting a record into the table, after the post the field "key" , witch is an (autonum) still empty.

ex)
MyTable.Insert;
DBEdit1.Field.Text:='Field 1';
MyTable.Post;

result)
ShowMessage(MyTable.Fields[0].AsString); //show nothing
ShowMessage(MyTable.Fields[1].AsString); //show Field 1

how can i get the key value?

jb
 
well.. i whant to catch the value of the PrimaryKey witch is an access autonum... any idea about how too do that?

jb
 
If the key field has a name you can use
MyTable.FieldByName('WhateverTheFieldNameIs').AsString;
 
I have do this:
1) Table.Close; // to flush the buffers
2) Table.Open;
3) Table.Last;
And then I get the autonumber value

Saludos de Argentina
Nicolás
 
tanx nicolas,

In fact that is exactly what i've done to solve my problem. I was wondering if there wasn't a way to do it without having to use such a "patch".
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top