M
malik via AccessMonster.com
Hi
I have a close Button name BtnClose
I have the following code for BtnClose :
Private Sub BtnClose_Click()
DoCmd.Close
End Sub
While I have the following Code in Form's Unload Event :
Private Sub Form_Unload(Cancel As Integer)
If Me.Dirty = True Then
Me.Undo
DoCmd.Close acForm, "FrmDrVoucher", acSaveNo
Else
Dim Ans As Integer
Ans = MsgBox("Do you want to exit without saving data?", vbYesNo +
vbInformation, "Confirm")
If Ans = vbYes Then
DoCmd.SetWarnings False
DoCmd.RunCommand acCmdDeleteRecord
DoCmd.SetWarnings True
Else
Cancel = True
End If
End If
End Sub
Now Problem Is that If I press Close button, a YesNo Msg box appears. If I
press Yes, It goes all ok.
But when I press No, It shows me the error
Run time error '2501'
The Close Action Was Cancelled
Wat to do????
Thank you.
I have a close Button name BtnClose
I have the following code for BtnClose :
Private Sub BtnClose_Click()
DoCmd.Close
End Sub
While I have the following Code in Form's Unload Event :
Private Sub Form_Unload(Cancel As Integer)
If Me.Dirty = True Then
Me.Undo
DoCmd.Close acForm, "FrmDrVoucher", acSaveNo
Else
Dim Ans As Integer
Ans = MsgBox("Do you want to exit without saving data?", vbYesNo +
vbInformation, "Confirm")
If Ans = vbYes Then
DoCmd.SetWarnings False
DoCmd.RunCommand acCmdDeleteRecord
DoCmd.SetWarnings True
Else
Cancel = True
End If
End If
End Sub
Now Problem Is that If I press Close button, a YesNo Msg box appears. If I
press Yes, It goes all ok.
But when I press No, It shows me the error
Run time error '2501'
The Close Action Was Cancelled
Wat to do????
Thank you.