Ok to save changes?

P

Paul

Good day....

How does one prompt a user to save changes? I have a form
to add clients. What I want to do is prompt the user
with 'OK to save changes' if they edit the form.

Cheers
 
A

Allen Browne

Use the BeforeUpdate event procedure of the *form*. That is the only way to
catch all the possible things that could trigger the saving of the record.

Private Sub Form_BeforeUpdate(Cancel As Integer)
If MsgBox("Save?", vbOkCancel) = vbCancel Then
Cancel = True
'Me.Undo
End If
End Sub
 
P

Paul

Thanks Allen!

-----Original Message-----
Use the BeforeUpdate event procedure of the *form*. That is the only way to
catch all the possible things that could trigger the saving of the record.

Private Sub Form_BeforeUpdate(Cancel As Integer)
If MsgBox("Save?", vbOkCancel) = vbCancel Then
Cancel = True
'Me.Undo
End If
End Sub

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.




.
 
J

John Vinson

Good day....

How does one prompt a user to save changes? I have a form
to add clients. What I want to do is prompt the user
with 'OK to save changes' if they edit the form.

Cheers

You can use the Form's BeforeUpdate event for this purpose:

Private Sub Form_BeforeUpdate(Cancel as Integer)
Dim iAns As Integer
iAns = MsgBox("OK to save changes?", vbYesNo)
Cancel = (iAns = vbNo)
End Sub

John W. Vinson[MVP]
(no longer chatting for now)
 

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