Solved

Write Conflict

Posted on 2011-03-14
9
381 Views
Last Modified: 2012-06-27
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
Comment
Question by:pdvsa
[X]
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
  • 6
  • 3
9 Comments
 
LVL 12

Expert Comment

by:ErezMor
ID: 35133537
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
 

Author Comment

by:pdvsa
ID: 35134402
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
 

Author Comment

by:pdvsa
ID: 35134431
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:pdvsa
ID: 35137153
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
 

Author Comment

by:pdvsa
ID: 35137287
that other post of:
frm
SELECT tblTransactions.* FROM tblTransactions ORDER BY tblTransactions.LCID;

was in error...
0
 
LVL 12

Accepted Solution

by:
ErezMor earned 500 total points
ID: 35140697
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
 

Author Comment

by:pdvsa
ID: 35141692
ahh i see.  Would this be by an INSERT?
0
 
LVL 12

Expert Comment

by:ErezMor
ID: 35152780
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
 

Author Comment

by:pdvsa
ID: 35152934
Interesting... Ill give it a try.  I think i follow you... Thank you
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

710 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