• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 397
  • Last Modified:

Write Conflict

Experts,

I have this nagging write conflict and i am not certain how to get rid of it.
I have the following on frmLetterOfCredit_Cont
Private Sub cboCountry_AfterUpdate()

     If IsNull(Me.cboRegion) Then
           DoCmd.OpenForm "frmRegionPopUp", , , "[LetterOfCreditID]=" & Me.ID, , acDialog
    'Me.Refresh
   
    End If

and it is a subform of Project Details.  

when the code executes the frmRegionPopUp appears and I enter data then close.
Then I am back on Parent form Project Details and sub LetterOfCredit_Cont.
When I move to another record on sub LetterOfCredit_Cont I get this Write Conflict error.  

I am familiar with this error and I believe you must save the record or requery it or something like that.

I have this on sub frmLetterOfCredit_Cont:
Private Sub Form_Dirty(Cancel As Integer)

    If Me.Dirty Then
        Me.Dirty = False
    End If
   
    DoCmd.RunCommand acCmdSaveRecord
   
End Sub
   
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
And on frmRegionPopUp:
'------------------------------------------------------------
' cmdClose_Click
''------------------------------------------------------------
Private Sub cmdClose_Click()
On Error GoTo cmdClose_Click_Err

    On Error Resume Next
    If (Form.Dirty) Then
        DoCmd.RunCommand acCmdSaveRecord
    End If
    If (MacroError.Number <> 0) Then
        Beep
        MsgBox MacroError.Description, vbOKOnly, ""
        Exit Sub
    End If
    On Error GoTo 0
    DoCmd.Close , ""


cmdClose_Click_Exit:
    Exit Sub

cmdClose_Click_Err:
    MsgBox Error$
    Resume cmdClose_Click_Exit

End Sub

~~~~~~~~~~~~~~~~~~~~~~~~
Any suggestions on how to get rid of the Write conflict?    Write conflict
0
pdvsa
Asked:
pdvsa
  • 6
  • 3
1 Solution
 
ErezMorCommented:
it's a bit hard t follow as it is, but for starters, when you want to reverse (or cancel) an event that has a "Cancel" parameter - like your Form_dirty event, you dont set the dirty property to false but instead write "cancel=1" (in fact any value other than 0)
now, if that doesnt mistakenly solve your problem, can you detail the actual tables and data each of the conflicting forms update, that can help in looking for a solution
0
 
pdvsaProject financeAuthor Commented:
ErezMor:
<can you detail the actual tables and data each of the conflicting forms update, that can help in looking for a solution
==>
Both forms are built off of the same table:  tblLetterOfCredit. When the frmREgionPopUp appears it is built off of tblLetterOfCredit just as frmLetterOfCredit_Cont.  When I am on frmLetterOfCredit_Cont, subform of the Parent Project Details (I dont think Project Details parent is the issue though), the frmRegionPopUp appears and I am updating one of the fields from tblLetterOfCredit.

So I am on tblLetterOfCredit by way of subform frmLetterOfCredit_Cont and updating a field by way of the frmREgionPopUp that is also built off of tblLetterOfCredit.  It might seem a little odd but that field is on anotehr form that users sometimes forget to input.  The network si a little slow and to open the form that contains this field would take some time so this is why I have the frmRegtionPopUp appearing to update that field instead of going to the actual form it resides.  

Whatdo you think now?


frm
SELECT tblTransactions.* FROM tblTransactions ORDER BY tblTransactions.LCID;

0
 
pdvsaProject financeAuthor Commented:
frmLetterOfCredit_Cont:
Private Sub cboCountry_AfterUpdate()

     If IsNull(Me.cboRegion) Then
    '    MsgBox "Enter the Region of Export on the LC Detail form (click LC No)", vbInformation
        DoCmd.OpenForm "frmRegionPopUp", , , "[LetterOfCreditID]=" & Me.ID, , acDialog
    'Me.Refresh
   
    End If
   
End Sub
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
pdvsaProject financeAuthor Commented:
I hope that helps a little with determining the problem.  Let me know if you need something else.  I might be able to post the db.  
0
 
pdvsaProject financeAuthor Commented:
that other post of:
frm
SELECT tblTransactions.* FROM tblTransactions ORDER BY tblTransactions.LCID;

was in error...
0
 
ErezMorCommented:
sorry for the delay
in general, if you have 2 open forms (doesnt matter if one of them is a popup) that are linked to the same table - you are asking for trouble. if you dont see another way to do it, then a possible solution is having the popup form (which updates fewer fields than the main form, right?) to be unbound. that means you'll load the data into it's textboxes and other controls upon opening the form, then when the user clicks "save" button, or close the form, you save the updated data back to the main form's field that was updated instead of updating the underlying table.
this way, the only form that will attempt to update is the main form (and your user wont feel the difference

some work there, but it's a safer, cleaner way to handle it
0
 
pdvsaProject financeAuthor Commented:
ahh i see.  Would this be by an INSERT?
0
 
ErezMorCommented:
if i understand your intention, then no, that's not an insert (unless your main form is doing a insert):
say you have a textbox "txtData" for the value, and a "save" command button on frmREgionPopUp form. and on the frmLetterOfCredit_Cont form, you have a visible (if you want your user  to see it) or hidden field fldData that is supposed to get the data from the popup form. then you write in the "save" click event:

Forms!frmLetterOfCredit_Cont!fldData=me!txtData
Docmd.Close Acform,"frmREgionPopUp"
0
 
pdvsaProject financeAuthor Commented:
Interesting... Ill give it a try.  I think i follow you... Thank you
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 6
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now