Increment SQL identity From Access Front End on save of record

  • Thread starter Jeff via AccessMonster.com
  • Start date
J

Jeff via AccessMonster.com

I have a button to save a rewly created record from Access to SQL backend
table. Here's my code...

DoCmd.Runcommand acCmdSaveRecord
Me.lot# = DMax("lot#", "tblSales") +1

I receive the following error:

"cannot insert explicit value for identity column in table tblSales when
Identity_insert is set to off."

Can anyone see what I need to add here?

Thanks,
 
S

Sylvain Lafontaine

If you want to write down your own values for the lot# column, don't use the
identity column property for this column.
 
W

Wolfgang Kais

Hello Jeff.
Jeff said:
I have a button to save a rewly created record from Access to SQL
backend table. Here's my code...

DoCmd.Runcommand acCmdSaveRecord
Me.lot# = DMax("lot#", "tblSales") +1

I receive the following error:

"cannot insert explicit value for identity column in table
tblSales when Identity_insert is set to off."

Can anyone see what I need to add here?

You should remove the second line. An identity column in a SQL Server
table works like an AutoIncrement field in an Access table.
SQL Severs controls the value himself.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top