Promt user do you wish to save changes

TheViruz30

Registered User.
Local time
Today, 11:49
Joined
Jan 21, 2006
Messages
33
I have a basic data entry form which is called frmPeople which has the following

First Name
Last Name
Address
City
State
Zip

What i want to do is if user changes/edits any of the information will prompt user do you wish to save changes yes/no

If user clicks yes will save info
if user clicks no will restore original info
 
Put this code in the Before Update event of your form:

Code:
Private Sub Form_BeforeUpdate(Cancel As Integer) 

Dim intResponse As Integer    
Dim strMsg As String    

strMsg = "Do you wish to save changes?"    
intResponse = MsgBox(strMsg, vbYesNo + vbExclamation, "Save Changes")    If intResponse = vbNo Then   
Me.Undo    
Else
End If 

End Sub

You'll also need ways to prevent your users from either closing the form or closing Access.

RV
 
Code Not Working

I Did as you said but the following code is in red so i attached a sample database.

intResponse = MsgBox(strMsg, vbYesNo + vbExclamation, "Save Changes") If intResponse = vbNo Then

See Attached


FYI

The Database i'm current working on is in MS 2000
 

Attachments

The If statement should start on a new line:

Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)

Dim intResponse As Integer
Dim strMsg As String

strMsg = "Do you wish to save changes?"
intResponse = MsgBox(strMsg, vbYesNo + vbExclamation, "Save Changes")
If intResponse = vbNo Then
Me.Undo
Else
End If

End Sub

RV
 

Users who are viewing this thread

Back
Top Bottom