View Full Version : Trying to save a new record but failing


Jon123
03-03-2011, 02:54 PM
I have read a few posts but very new to sql and could use some help.

I have a save button on a form that runs this code

DoCmd.GoToRecord , , acNewRec

But it does not work. It worked in access but not is sql any ideas ?

please help

boblarson
03-03-2011, 06:54 PM
Make sure the table in SQL Server has a primary key defined.

Jon123
03-04-2011, 03:49 AM
Yes the table has a PK

boblarson
03-04-2011, 06:53 AM
Okay, so can you update the table manually? Will changes be there? If so, then maybe try this in the form BEFORE trying to move to another record:


If Me.Dirty Then Me.Dirty = False

Jon123
03-04-2011, 06:55 AM
I set the PK idenity field to YES and now its working. Could you tell me why that fixed it?

boblarson
03-04-2011, 07:12 AM
I set the PK idenity field to YES and now its working. Could you tell me why that fixed it?

My guess is that your original Access table had an autonumber PK and SQL Server's autonumber is IDENTITY.