473,466 Members | 1,464 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Getting the Write Conflict Error

37 New Member
I am trying to update a record using access as the front end and VB 6.0 as the backend. I am using a SQL statement to accomplish this. But I am getting the "Write Conflict Error". I have tried adding the 'Timestamp field as someone suggested but that isn't working. Here is my code. Please advise
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdAddRec_Click()
  2. On Error GoTo Err_cmdAddRec_Click
  3.  
  4.  
  5. Dim rstTrans As New ADODB.Recordset
  6. Dim fld As ADODB.Field
  7. Dim strField As String
  8. Dim Msg, Response
  9.  
  10.  
  11. Msg = "Do you want to update another record?"
  12.  
  13. Sqlstmt = "SELECT * FROM dbo_tbl_HR_Shuttle WHERE VehicleID = " & Form_Daily_Vehicle_Tic_Sheet_Data_Form!VehicleID
  14.  
  15. rstTrans.Open Sqlstmt, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
  16.  
  17. rstTrans!DateModified = Now()
  18. rstTrans!UpdateUser = gUser
  19.  
  20.  
  21. rstTrans.Update
  22. 'DoCmd.Save
  23. Response = MsgBox(Msg, vbYesNo)
  24. If Response = vbYes Then
  25. 'MsgBox ("result is yes")
  26. DoCmd.Close
  27. DoCmd.OpenForm "Daily_Vehicle_Tic_Sheet_Data_Form"
  28. Else
  29.     DoCmd.Close
  30. End If
  31. rstTrans.Close
  32.  
  33. Exit_cmdAddRec_Click:
  34.     Exit Sub
  35.  
  36. Err_cmdAddRec_Click:
  37.     MsgBox Err.Description
  38.     Resume Exit_cmdAddRec_Click
  39.  
  40. End Sub
Sep 26 '07 #1
2 2358
NeoPa
32,556 Recognized Expert Moderator MVP
Please look in POSTING GUIDELINES: Please read carefully before posting to a forum and consider rewording your question or adding extra relevant information. As it stands I'm afraid, it's too unclear.

ADMIN.

NB. VB6 is a programming language (can't be a back-end)
We are not a code debugging service.
Oct 6 '07 #2
Jim Doherty
897 Recognized Expert Contributor
I am trying to update a record using access as the front end and VB 6.0 as the backend. I am using a SQL statement to accomplish this. But I am getting the "Write Conflict Error". I have tried adding the 'Timestamp field as someone suggested but that isn't working. Here is my code. Please advise
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdAddRec_Click()
  2. On Error GoTo Err_cmdAddRec_Click
  3.  
  4.  
  5. Dim rstTrans As New ADODB.Recordset
  6. Dim fld As ADODB.Field
  7. Dim strField As String
  8. Dim Msg, Response
  9.  
  10.  
  11. Msg = "Do you want to update another record?"
  12.  
  13. Sqlstmt = "SELECT * FROM dbo_tbl_HR_Shuttle WHERE VehicleID = " & Form_Daily_Vehicle_Tic_Sheet_Data_Form!VehicleID
  14.  
  15. rstTrans.Open Sqlstmt, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
  16.  
  17. rstTrans!DateModified = Now()
  18. rstTrans!UpdateUser = gUser
  19.  
  20.  
  21. rstTrans.Update
  22. 'DoCmd.Save
  23. Response = MsgBox(Msg, vbYesNo)
  24. If Response = vbYes Then
  25. 'MsgBox ("result is yes")
  26. DoCmd.Close
  27. DoCmd.OpenForm "Daily_Vehicle_Tic_Sheet_Data_Form"
  28. Else
  29. DoCmd.Close
  30. End If
  31. rstTrans.Close
  32.  
  33. Exit_cmdAddRec_Click:
  34. Exit Sub
  35.  
  36. Err_cmdAddRec_Click:
  37. MsgBox Err.Description
  38. Resume Exit_cmdAddRec_Click
  39.  
  40. End Sub

Given you have posted your program flow I'm not going to debug alter it per se you obviously have it in that order for a particular reason I assume?

My guess on this based on your post is that the form on which your cmdAddRec button is mounted has its recordsource bound to the table and that you are asking to open THE SAME TABLE as a second recordset in code. In other words you have TWO datasets open derived from the same table. if this is 'not bound' then you must have at least the same table open in memory twice.

The 'write conflict' will be occurring IF at the point at which the user (or 'you' as its in in development at this stage) clicks the command button, and the record is in an 'EDIT' state (look at the record selector left hand side of the form, if you see the pencil then it most certainly is) the row that you wish to update will be LOCKED and as such non editable until such time as you SAVE the current record BEFORE opening the second recordset in code.

If I am correct in my assumption then you will need to save the record BEFORE opening the second recordset in code.

The form from which you have clicked the command button will be in what is referred to as a DIRTY state ie: 'unsaved' a condition that will be TRUE. You need to reverse that stateto FALSE this in turn saves the record if you understand me.

The line of code you need at the appropriate point and I leave that up to you to decide its placement in your logic is this

Expand|Select|Wrap|Line Numbers
  1.  If Me.Dirty = True Then Me.Dirty = False

Regards

Jim
Oct 6 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Vipul Pathak | last post by:
Hello Friends ! I have the Following Code, that Executes a Stored Procedure and Attempt to read a Returned Integer Value from the StoredProc. But It gives Error ... ADODB.Command (0x800A0BB9)...
1
by: Kuriandungu | last post by:
Hi guys I've read the posts on Write conflict entered in this forum (along with some from kbAlertz and microsoft) and i have tried all the solutions without success. let me give you some background....
1
by: lorirobn | last post by:
Hi, I have a query that I have been using as a record source for a form with no problems. I just created a new "addnew" form, and added 20 records to the table with this form. The problem I...
8
by: christianlott1 | last post by:
After searching the group and the net, I just can't believe after all this work I'm going to have to sit through three Write Conflict messages when I want to roll back and delete a record. The...
7
by: PW | last post by:
Hi, I have a form with unbound fields on it. The user selects a record from a recordset and I populate the unbound fields. When I try to change the unbound quantity text box, Access 2003 tells...
1
by: S.Dickson | last post by:
I have a database with access as front end and Mysql as back end. I am gettting the following 'Write Conflict' Error. when i am on my order form, This form does has a subform where i enter all the...
2
Megalog
by: Megalog | last post by:
Hey all, I have a minor issue I'm trying to figure out (using Access 2007). I'm using a DAO recordset to update a table ("Writeups"), with the results of a bunch of functions I've written up over...
3
by: gazsharpe101 | last post by:
Hi everyone, I am doing some work on my company's database. It is a MS Access 2003 front-end with an SQL back-end. Recently, I have asked the database administrator to add some new fields to...
1
by: cwfontan | last post by:
I am uploading a file renaming it with text from input here is the sql insert code and error im getting. If you need more of the code let me know.. This exact code is working when inserting into...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.