Solved

Error trying to update linked SQL Server table

Posted on 2011-09-08
3
250 Views
Last Modified: 2012-05-12
I am using the below code to try to edit a linked SQL server table from an Access front end.

It returns the following error:
Error 3197: The Microsoft Jet database engine stopped the process because you and another user are attempting to change the same data at the same time.

If I try to edit the record directly in the table, I receive the error in  the screenshot.  

 I am able to create records ok.

There are no other users in this database at any time.


With CurrentDb.OpenRecordset("SELECT * FROM dbo_TimeSheets WHERE TransactionID=" & Me.TransactionID, dbOpenDynaset, dbSeeChanges)
               
                   .Edit
                     !order = Me.order
                     !EmployeeID = Me.EmployeeID
                     !Labor_Date = Me.Labor_Date
                     !No_Of_Hours = Me.No_Of_Hours
                   .Update
                   .Close

    End With

Open in new window

write.bmp
0
Comment
Question by:snyperj
3 Comments
 
LVL 24

Accepted Solution

by:
Bitsqueezer earned 500 total points
ID: 36505383
Hi,

in most cases this can be solved by adding a field to any table which is used by Access of type "timestamp". The problem is that often the datatypes are not converted correctly between JET and SQL Server and then there would be a difference between the original record and the edited one because in this case there is a field by field compare. With a timestamp SQL Server only looks into this field to compare the record.

Another reason why this error can occur is that a change in the code is the same as if another user had changed the record. So if you change the record directly while it is displayed in a form it's the same as if another user had changed something.

Cheers,

Christian
0
 
LVL 9

Expert Comment

by:borki
ID: 36505395
Not sure how you are linking to SQL, this might be the source of the problem, as the Jet engine can't control the server.

Personally I would be using an Update statement such as

dim sSQL as string

sSql = "UPDATE dbo_TimeSheets SET order = " & me.order & " WHERE TransactionID=" & Me.TransactionID"
Docmd.RunSQL (sSql)
0
 

Author Closing Comment

by:snyperj
ID: 36505924
Yes- that seems to have done it (adding the timestamp)
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question