Increment SQL identity From Access Front End on save of record

  • Thread starter Thread starter Jeff via AccessMonster.com
  • Start date 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,
 
If you want to write down your own values for the lot# column, don't use the
identity column property for this column.
 
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.
 
Back
Top