Solved

Write Conflict

Posted on 2011-03-14
9
342 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
 

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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now