Write Conflict

lmcc007

Registered User.
Local time
Today, 17:43
Joined
Nov 10, 2007
Messages
635
In my table I have a field called CompanyTagged (yes/no data type) which I am using by tagging companies indvidually. And a field call TaggedExplanation--where you can jot down a note why you tagged this record. If the checkbox is checked it will display a label with the word TAGGED and bring up the form to enter TaggedExplanation data.

Now, I keep getting this error message:

Write Conflict:

This record has been changed by another user since you started editing it. If you save record, you will overwrite the changes the other user made.

Copying the changes to the clipboard will let you look at the values the other user entered, and then paste your changes back in if you decide to make changes.

Save Record Copy to Clipboard Drop Changes


Below is the code I am using:

Code:
Private Sub Form_Current()

    If Me!chkCompanyTagged.Value = -1 Then
        Me!lblTagged.Visible = True
    Else
        Me!lblTagged.Visible = False
    End If
    

End Sub

-------------------------------------------------------------------------


Private Sub chkCompanyTagged_Click()
   
    If Me!chkCompanyTagged.Value = -1 Then
        Me!lblTagged.Visible = True
        DoCmd.OpenForm "fdlgCompanyTaggedExplanation", , , "CompanyID = " & Me!txtCompanyID
    Else
        If Me.chkCompanyTagged.Value = 0 Then
            ' Make sure fdlgCompanyTaggedExplanation is open
            If Not IsFormLoaded("fdlgCompanyTaggedExplanation") Then
                Me!lblTagged.Visible = False
            Else
                Forms!fdlgCompanyTaggedExplanation!CompanyTaggedExplanation.Value = Null
                DoCmd.Close acForm, "fdlgCompanyTaggedExplanation", acSaveYes
                Me!lblTagged.Visible = False
            End If
        End If
    End If    

End Sub


Using Access 2007, only user, not network--at home PC.

Any ideas why?
 
Seen this error myself. I would place this line as the first line of your currentevent or chkcompantagged and see if that solves it.

The other point is that the CurrentEvent may be in conflict with the chkcompantagged. Why are you using currentevent rather than On Load?

Docmd.RunCommand accmdsaverecord
 
The other point is that the CurrentEvent may be in conflict with the chkcompantagged. Why are you using currentevent rather than On Load?

Because the label will change per record. If record 1 is checked, the label is displayed. If record 2 is not checked, the label will not display and so on.
 
You're either having the error in the 2nd ELSE block or when the record is being saved in the form that opens.

To prevent the first case mentioned use this:
Code:
                DoCmd.Close acForm, "fdlgCompanyTaggedExplanation", acSaveYes
                Me!lblTagged.Visible = False
For the second case, requery the main form in the After_Update event of fdlgCompanyTaggedExplanation.
 
Last edited:
For the second case, requery the main form in the After_Update event of fdlgCompanyTaggedExplanation.

I am not getting the error message now. Below is the code I am using:

Code:
Private Sub chkCompanyTagged_Click()

On Error GoTo ErrorHandler
    
    DoCmd.RunCommand acCmdSaveRecord
    
    If Me!chkCompanyTagged.Value = -1 Then
        Me!lblTagged.Visible = True
        DoCmd.OpenForm "fdlgCompanyTaggedExplanation", , , "CompanyID = " & Me!txtCompanyID
    Else
        If Me.chkCompanyTagged.Value = 0 Then
            ' Make sure fdlgCompanyTaggedExplanation is open
            If Not IsFormLoaded("fdlgCompanyTaggedExplanation") Then
                Me!lblTagged.Visible = False
            Else
                Forms!fdlgCompanyTaggedExplanation!CompanyTaggedExplanation.Value = Null
                DoCmd.Close acForm, "fdlgCompanyTaggedExplanation", acSaveYes
                Me!lblTagged.Visible = False
            End If
        End If
    End If
    

CleanUpAndExit:
    Exit Sub

ErrorHandler:
    Call MsgBox("An error was encountered" & vbCrLf & vbCrLf & _
        "Description:  " & Err.Description & vbCrLf & _
        "Error Number:  " & Err.Number, vbCritical, gstrAppTitle)
    Resume CleanUpAndExit

End Sub

I think I understand now why I got the error; without the accmdSaveRecord, it was trying to open another form before saving the changes in current form.

Are you saying I still need to add changes?
 
Happens when you've got two forms open with the same record source and both forms are editting a record a record without commiting the edits.
 
Happens when you've got two forms open with the same record source and both forms are editting a record a record without commiting the edits.

Got it--makes sense.

So, the code is okay, huh? I don't need to add "requery the main form in the After_Update event of fdlgCompanyTaggedExplanation.".
 
If that's working for you then you don't have to do anything else, although you don't need acSaveYes because that's only saving design changes not record changes.

The other thing is how are checking whether a form is open via the IsFormLoaded function you created?

Lastly, you don't need the Call statement in the error handler bit.
 
The other thing is how are checking whether a form is open via the IsFormLoaded function you created?

Lastly, you don't need the Call statement in the error handler bit.

Not understanding the above.

Are you asking me if the IsFormLoaded function working?

Are you saying Call need to be removed or the entire statement?
 
...although you don't need acSaveYes because that's only saving design changes not record changes.

Code:
Forms!fdlgCompanyTaggedExplanation!CompanyTaggedExplanation.Value = Null
                DoCmd.Close acForm, "fdlgCompanyTaggedExplanation", acSaveYes
                Me!lblTagged.Visible = False

Okay, I was thinking that the above code would:

1. Clear the field "CompanyTaggedExplanation" of any data.
2. Close the form and save any changes (that is the clearing of the data)
3. And make the label invisible.
 
Don't worry about the other bit, an msgbox doesn't need the Call statement.
 
Don't worry about the other bit, an msgbox doesn't need the Call statement.

This entire statement?

Code:
    Call MsgBox("An error was encountered" & vbCrLf & vbCrLf & _
        "Description:  " & Err.Description & vbCrLf & _
        "Error Number:  " & Err.Number, vbCritical, gstrAppTitle)

Are just the word "Call"? If so, does it matter? Because I read somewhere you should try to be as specific as possible when writing code.
 
Code:
Forms!fdlgCompanyTaggedExplanation!CompanyTaggedExplanation.Value = Null
                DoCmd.Close acForm, "fdlgCompanyTaggedExplanation", acSaveYes
                Me!lblTagged.Visible = False
Okay, I was thinking that the above code would:

1. Clear the field "CompanyTaggedExplanation" of any data.
2. Close the form and save any changes (that is the clearing of the data)
3. And make the label invisible.
Just noticed this reply. It's doing all but saving changes to the record. When you close the form any changes made is commited anyway.

The link works on mine, Firefox that is. It just basically shows you how an Msgbox is called so you basically don't need to add Call there.
 
Just noticed this reply. It's doing all but saving changes to the record. When you close the form any changes made is commited anyway.

The link works on mine, Firefox that is. It just basically shows you how an Msgbox is called so you basically don't need to add Call there.

Oh boy, after adding "DoCmd.RunCommand acCmdSaveRecord" now I am getting Error 2448.

Should I write this code another way?
 
There are thousands of error codes, what is the exact error message?
 
I've got many dbs open at the mo, just the error message will be sufficient.
 
Check that the control you're trying to assign to doesn't have a calculated Control Source, something begininning with "="
 

Users who are viewing this thread

Back
Top Bottom