By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,347 Members | 2,113 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,347 IT Pros & Developers. It's quick & easy.

insert into sqlserver with autonumber

P: 2
Hi all, i have a problem.
In my access-application i am trying to insert a record in a linked table with resides in a sqlserver 2000 database. However, the primary key in that table is an INT with identity. I would expect that sqlserver automatically determines the next unique primary-key value (increment = 1) but it seems that it doesn't. I get a primary-key violation. Is there a way to insert a record from access in sqlserver when the table has a autonumberfield as a primary-key.

I use the next statement (of course, i don't specify the primary-key value).

sqlstring = "INSERT INTO dbo_tblSwitchVerzoeken (ZakenPartner, EAN, Product, LeverancierID, Invoerder) VALUES (" & sZakenpartnernummer & "," & sEancode & ", '" & Left(sProdukt, 1) & "'," & sLeverancier & "," & sIngedienddoor & ")"

DoCmd.RunSQL sqlstring

Thans for any suggestions.

Mark
Feb 14 '08 #1
Share this Question
Share on Google+
1 Reply


Delerna
Expert 100+
P: 1,134
I don't understand your difficulty, I do it all the time. Are you sure the table was set up that way before you linked to it from access. Try deleting the link and re-linking it
Feb 17 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.