Delphi problems with Access Autonumber field.

Is there a trick to posting a new record to Access when there's an Autonumber field involved? I'm using .Append, setting the field values, and then using the .Post and I get an error if I don't set the autonumber value and I also get an error if I do set the autonumber value.  Any ideas?
dokkenAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
kretzschmarConnect With a Mentor Commented:
well dokken,

just pasted:

set the required-flag to false on this field, if you have persistent fields.

if not then set this line after the open-statement
table1.FieldByName('NameOfField').Required := False;

glad to helped you
good luck again

meikl ;-)
0
 
RBertoraCommented:
I think basically you are in trouble unless you use TQuery.

Using a TQuery you can do something along the lines..

Query1.Sql.Clear;
Query1.Sql.Add(
'insert into tablename values(field2,field3) values('One',500)' );
Query1.Open;

and similar thing for update..

note you do not provide field1 as it is autoinc field.

Rob;-)
0
 
RBertoraCommented:
Ah, sorry Query1.Execsql;
Rob ;-)
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

 
kretzschmarCommented:
hi dokken,

just set the required-flag to false on this field, if you have persistent fields.

if not then set this line after the open-statement
table1.FieldByName('NameOfField').Required := False;

meikl ;-)
0
 
dokkenAuthor Commented:
Meikl,

That worked great, post it as an answer so I can give you the points.
0
 
dokkenAuthor Commented:
Thanks for the answer... it helped a lot.
0
All Courses

From novice to tech pro — start learning today.