confirm saving

F

Fatma

Hi all
i've a form that i need to confirm updating it's data before closing it
with yes-no-Cancel msgbox
it does work with yes - No
but with cancel it raise an error "2427" in form_error event
the code is in Form_BeforeUpdate
some thing like this:
------------------------
Private Sub Form_BeforeUpdate(Cancel As Integer)
On Error GoTo Err_Form_BeforeUpdate
Dim intResponse As Integer
intResponse = MsgBox("Save data?", vbYesNoCancel, "Confirm")
Select Case intResponse
Case vbYes
Me.Agent = CurrentUser()
Case vbNo
If MsgBox("Delete Data?", vbOKCancel, "Confirm") = vbOK Then
Me.Undo
Else
Cancel = True
End If
Case vbCancel
Cancel = True
End Select
End If
Exit_Form_BeforeUpdate:
Exit Sub
Err_Form_BeforeUpdate:
MsgBox Err.Description
Resume Exit_Form_BeforeUpdate
End Sub
 
F

Fatma

note 1: sorry, remove the end if
note 2: yes it is a bound text box that saves the current user name (even
when removing it the error still there)
the problem occurs when closing the form & only if I choose cancel from the
yes -no -cancel msgbox .
I think the error is that I'm trying to cancel the close in the
Form_BeforeUpdate event
while I've to cancel it in the Form_Unload event

anyway thanks for your help
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top