Reputation: 313
I have this form in Access with a bunch of drop down menu boxes. If I choose a value from the List and then change my mind and leave it blank again, click close, I always get this message:
the data has been changed
Another User edited this record and saved the changes
before you attempted to save your changes
Re-edit the record.
I have 3 different macros in the background running for
Deal type
Loan Exception Comments
Update Flags
I don't think those macros would affect anything to give that error. But can I write something so that it catches this error message and ignores it and proceeds to close when I click close?
The main form VBA has this code:
Private Sub Close_Click()
Me.FrmJobDetails.Form.Requery
Me.subform1.Form.Requery
If Me.FrmJobDetails.Form.Dirty = True Then 'what I tried adding
me.FrmJobDetails.Form.Dirty = False 'what I tried adding
End If
If Me.subform1.Form.Dirty = True Then 'what I tried adding
me.subform1.Form.Dirty = False 'what I tried adding
End If
DoCmd.SetWarnings (WarningsOff)
DoCmd.Save
entry
DoCmd.OpenQuery ("aqrySBORequestSiteDetail"), , acReadOnly
DoCmd.Close
DoCmd.SetWarnings (WarningsOn)
End Sub
In that code, with the comment "what I tried adding" is what I thought could prevent that error message from occurring.
Any suggestions?
Upvotes: 0
Views: 2530
Reputation: 11
Thanks! I found this to work on my end. Same script, but DataErr 7878 instead.
Private Sub Form_Error(DataErr As Integer, Response As Integer)
If DataErr = 7878 Then
Response = acDataErrContinue
On Error Resume Next
With Me.Recordset
.MovePrevious
.MoveNext
End With
On Error GoTo 0
End If
End Sub
Upvotes: 1
Reputation: 8518
I use this to handle the Write Conflict error (7787). When there's a write conflict, the first change goes through and the second one gets discarded.
Private Sub Form_Error(DataErr As Integer, Response As Integer)
If DataErr = 7787 Then
Response = acDataErrContinue
On Error Resume Next
With Me.Recordset
.MovePrevious
.MoveNext
End With
On Error GoTo 0
End If
End Sub
Upvotes: 2
Reputation: 90
Well... to skip it:
On Error Resume Next
At the top of the Macro will skip any commands with errors.
This won't fix the cause, but it will stop popping up the errors.
Upvotes: 1