write conflict

ramblinwreck

Registered User.
Local time
Today, 14:19
Joined
Apr 13, 2007
Messages
28
I have a control on a subform called chkOrdered that I use to update a record to indicate that an associated part has been ordered.

When I click the checkbox, code executes and returns (and the record is updated accordingly). Then, when I move to the next record, I get a messagebox indicating that someone else has changed the same record since I started updating it and asking me if I want to save the changes or write to the clipboard.

Interestingly, if I click the checkbox after the record has been updating (indicating that a part was previously ordered and am now saying no part has been ordered), I get no such message box when moving to a different record.

here's the code:

Code:
Private Sub chkOrdered_Click()
On Error GoTo Error_Handler:
Dim dbs As Database
Dim rst As DAO.Recordset
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("tblpartsinfo", dbOpenTable)
'following if statement determines whether or not part has already been ordered based on
'value of intclick.  if intclick is zero, no order info has been stored in record.
If intclick = 0 Then
Me.txtOrdered.Enabled = True
    If Not NewRecord Then
        With rst
            .Index = "idspartsinfoid"
            .Seek "=", Me.txtParkKey
            .Edit
            'write to record that the part has been ordered
            !blnOrderedYet = -1
            .Update
        End With
        intclick = 1
        Me.dtmOrdered = Date
        Me.dtmOrdered.Enabled = False
    End If
Else
Me.txtOrdered.Enabled = False
'set value of inclick to reflect that record currently shows no order info
intclick = 0
End If
exit_procedure:
Close
Set rst = Nothing
DoCmd.Hourglass False
DoCmd.SetWarnings True
Exit Sub
Error_Handler:
On Error Resume Next
MsgBox "An error has occurred in this application. " _
& "Please contact your technical support person and tell them this information:" _
& vbCrLf & vbCrLf & "Error Number " & Err.Number & ", " & Err.Description, _
Buttons:=vbCritical, title:="My Application"
Resume exit_procedure
Resume
End Sub

Attached is picture of the messagebox.

Wanting to know how to make this messagebox go away.
 

Attachments

  • Write Conflict.gif
    Write Conflict.gif
    96.5 KB · Views: 152
Try adding a

Docmd.runcommand acCmdSaveRecord

after you update the record with your code. I believe you are running into problems because you modify the record then your code also modifies the same record and Access assumes that to different people are making updates to the same record.
 
ok thanks. i'll add that. I thought that was what the ".update" was for in the code. Am I wrong?
 

Users who are viewing this thread

Back
Top Bottom