Write Conflict (1 Viewer)

Lissa

Registered User.
Local time
Today, 14:59
Joined
Apr 27, 2007
Messages
114
I have a main form (frmIncmgInspectLog) that lets the user select a purchase order (PO) from a dropdown list. After that field is updated with a PO value, that opens another form that contains a list box with information about hardware parts ordered by the selected PO. The user selects a part and the OnClick event triggers an update event that will update some fields back on the main form.
I don't see the update immediately on the main form. When I click to the next record I see a message about a Write Conflict (see attachment).

1) If I have the main form open - can I not write to the current record?
2) How can I bypass or surpress the Write Conflict message?

Here is my code from the list box on the form that is called by the main form

Private Sub List0_Click()
Dim strSQL As String
Dim PartNum As String
Dim Nomen As String
Dim Qty As Integer
Dim Due As Date
Dim key As Integer

PartNum = Me.PartNumber
Nomen = Me.Nomenclature
Qty = Me.Quantity
Due = Me.DueDate

'Update the Incmg Inspection Log with the selected information
strSQL = "UPDATE tblINCOMING_INSPECT_LOG SET PartNumber = '" & PartNum & "', Nomenclature = '" & Nomen & "', QtyOrdered = " & Qty & ", DateShpDue = # " & Due & " # WHERE IncmgInspectLogID = " & updKey & " ;"
MsgBox "SQL: " & strSQL 'Debug: check my statement
CurrentDb.Execute strSQL, dbFailOnError
MsgBox "Table has been updated!" 'Debug
DoCmd.Close

End Sub

Thanks!
 

Attachments

  • writeConflict.jpg
    writeConflict.jpg
    92.8 KB · Views: 189

boblarson

Smeghead
Local time
Today, 12:59
Joined
Jan 12, 2001
Messages
32,059
The problem is likely that you have a bound form that is bound to the same record source as the query is trying to update. If that is the case then issue a save record command on the main form before opening the other form.

DoCmd.RunCommand acCmdSaveRecord

or use

If Me.Dirty Then Me.Dirty = False

(which would do the same but would only save if something had been modified or added).
 
Last edited:

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 20:59
Joined
Sep 12, 2006
Messages
15,710
if the record is dirty (ie edited) when you open the popup, you wont be able to save changes affecting the main form

one solution is to save the record before opening the popup

if me.dirty then dirty=false

or

runcommand accmdsaverecord

both do the same job
 

boblarson

Smeghead
Local time
Today, 12:59
Joined
Jan 12, 2001
Messages
32,059
if the record is dirty (ie edited) when you open the popup, you wont be able to save changes affecting the main form

one solution is to save the record before opening the popup

if me.dirty then dirty=false

or

runcommand accmdsaverecord

both do the same job
Wow, great minds do think alike (well, yours is great - mine is borderline psycho :D )
 

Lissa

Registered User.
Local time
Today, 14:59
Joined
Apr 27, 2007
Messages
114
I'm almost there... I tried putting DoCmd.RunCommand acSaveRecord in the After Update event just before the command to open the other form and I get this:

You can't compact the open database while running a macro or Visual Basic code.
Instead of using a macro or code, on the Tools menu, point to Database Utilities, and then click Compact/Repair Database.

How weird... let me try the 'dirty way' LOL
 

boblarson

Smeghead
Local time
Today, 12:59
Joined
Jan 12, 2001
Messages
32,059
I had a typo (should be acCmdSaveRecord, not acSaveRecord)
 

Lissa

Registered User.
Local time
Today, 14:59
Joined
Apr 27, 2007
Messages
114
Awesome-ness! You guys rock!!

Both statements worked - after the typo was corrected. :)

Thanks!!
Lissa
 

Users who are viewing this thread

Top Bottom