If Err.Number = 0 Or Err.Number = 2501 Then Err.Clear 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 Me.subIMenuCondition.SetFocus DoCmd.SetWarnings False 'hides the do you want to delete this record message DoCmd.RunCommand acCmdUndo 'to undo changes on the subform Else DoCmd.RunCommand acCmdSaveRecord DoCmd.OpenForm "FRM_NewForm", acNormal End If Else DoCmd.OpenForm "FRM_NewForm", acNormal End If DoCmd.SetWarnings True
From novice to tech pro — start learning today.