Solved

Write Conflict

Posted on 2011-03-14
9
364 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
  • 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
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 

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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Suggested Solutions

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

772 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