Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Error trying to update linked SQL Server table

Posted on 2011-09-08
3
251 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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
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, when working with VBA, learn some techniques for writing readable and easily maintained code.

860 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