Solved

Error trying to update linked SQL Server table

Posted on 2011-09-08
3
248 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
Comment Utility
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
Comment Utility
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
Comment Utility
Yes- that seems to have done it (adding the timestamp)
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

728 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now