From: Ashley on
I have the embeded macro onClick event to close the form and set save to
prompt. But it didn't prompt when it close the form.
I also have below event in my form and it still not prompting to save. What
I need to check? Thanks
Private Sub Form_BeforeUpdate(Cancel As Integer)
'get user confirmation of whether to save record or not
If MsgBox("Do you want to save the new BOM?", vbYesNo) = vbNo Then
Me.Undo
Cancel = True
End If
End Sub
From: Jeanette Cunningham on
If you use the line Cancel = True in the before update event, the form will
not close.
I suggest you put a close button with code something like this

Private Sub cmdClose_Click()
If Me.Dirty = True Then
If MsgBox("Do you want to save the new BOM?", vbYesNo) = vbNo Then
Me.Undo
Else
'other code here if needed to check data before save
End If
End If
DoCmd.Close acForm, Me.Name
End Sub


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia


"Ashley" <Ashley(a)discussions.microsoft.com> wrote in message
news:D7723472-9BBE-445C-A431-6554B7A4E5F2(a)microsoft.com...
>I have the embeded macro onClick event to close the form and set save to
> prompt. But it didn't prompt when it close the form.
> I also have below event in my form and it still not prompting to save.
> What
> I need to check? Thanks
> Private Sub Form_BeforeUpdate(Cancel As Integer)
> 'get user confirmation of whether to save record or not
> If MsgBox("Do you want to save the new BOM?", vbYesNo) = vbNo Then
> Me.Undo
> Cancel = True
> End If
> End Sub