troubleshooting Question

MS Access Error Handling

Avatar of TechNinja2
TechNinja2 asked on
Microsoft AccessVBA
6 Comments1 Solution193 ViewsLast Modified:

My deadline is nearing and my time is shortening.  This may be an easy answer.  I'm just running out of time to troubleshoot and figure it out.  I have this code on the click event of a command button to switch to another form (I used generic control references since it is for a client):

    If Err.Number = 0 Or Err.Number = 2501 Then
    End If
    On Error Resume Next
    If IsNull(Me.ComboBox) Then
        MsgBox "No Item Was Selected." & vbCrLf & "Please select an item from the pull-down menu before proceeding.", vbExclamation + vbOKOnly, "Select Item"
    End If
    If (Form.Dirty Or Not Me.subForm.Form.NewRecord) Then     'if I use Me.subForm.Form.Dirty the undo doesn't work on the subform
        If MsgBox("This record has been changed.  Do you want to save changes?", vbQuestion + vbYesNo, "Save Changes?") = vbNo Then
            DoCmd.RunCommand acCmdUndo     'to undo changes on the main form
            DoCmd.SetWarnings False     'hides the do you want to delete this record message
            DoCmd.RunCommand acCmdUndo     'to undo changes on the subform
            DoCmd.RunCommand acCmdSaveRecord
            DoCmd.OpenForm "FRM_NewForm", acNormal
        End If
        DoCmd.OpenForm "FRM_NewForm", acNormal
    End If
    DoCmd.SetWarnings True

A little background on the form.  The user selects an item from the unbound Me.ComboBox, which then populates a few other unbound combo boxes in the header, jumps to the record by ID# in Me.ComboBox and shows details in the subform.  It all works great and the undo works fine.  I just get the "This record has been changed" message when I select an Item from the unbound Me.ComboBox but have made no other changes to the form.  How do I change the code so I only get this message when I change bound controls/fields?

Join our community to see this answer!
Unlock 1 Answer and 6 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros