Confirm Record Changes

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I cannot get this to work under OPTIONS, EDIT/FIND. All I want to do is make sure a confirmation warning pops up when a change is made in our database. The Confirm Document Deletion option doesn't work either.

I have tried attaching code, but that seems to work only part of the time.

Need help bad...

Thanks.
 
Voltaire,

That only works with datasheet actions, action queries, and certain VBA
methods - not with forms. To get that functionality in forms, you'll have to
code it yourself.

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia

Microsoft Access 2003 VBA Programmer's Reference
http://www.wiley.com/WileyCDA/WileyTitle/productCd-0764559036.html


Voltaire said:
I cannot get this to work under OPTIONS, EDIT/FIND. All I want to do is
make sure a confirmation warning pops up when a change is made in our
database. The Confirm Document Deletion option doesn't work either.
 
Thanks Graham, that was helpful. I have tried coding too, unfortunately, it only seems to work if I code each text label. Nothing seems to happen if I do the following:

Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim strMsg As String
strMsg = "Data has changed."
strMsg = strMsg & "@Do you wish to save the changes?"
strMsg = strMsg & "@Click Yes to Save or No to Discard changes."
If MsgBox(strMsg, vbQuestion + vbYesNo, "Save Record?") = vbYes Then
'do nothing
Else
DoCmd.RunCommand acCmdUndo

'For Access 95, use DoMenuItem instead
'DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
End If
End Sub

However, it will work for that particular text field, if I input the following:

Private Sub Text160_BeforeUpdate(Cancel As Integer)
Dim strMsg As String
strMsg = "Data has changed."
strMsg = strMsg & "@Do you wish to save the changes?"
strMsg = strMsg & "@Click Yes to Save or No to Discard changes."
If MsgBox(strMsg, vbQuestion + vbYesNo, "Save Record?") = vbYes Then
'do nothing
Else
DoCmd.RunCommand acCmdUndo

'For Access 95, use DoMenuItem instead
'DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
End If
End Sub

Any thoughts? Thanks.
 
Voltaire,

You can't cancel the update like that. You must instead cancel the form's
update, then set the Cancel parameter.

Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim strMsg As String
strMsg = "Data has changed."
strMsg = strMsg & "@Do you wish to save the changes?"
strMsg = strMsg & "@Click Yes to Save or No to Discard changes."
If MsgBox(strMsg, vbQuestion + vbYesNo, "Save Record?") = vbYes Then
'do nothing
Else
Me.Undo
Cancel = True
End If
End Sub


Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia

Microsoft Access 2003 VBA Programmer's Reference
http://www.wiley.com/WileyCDA/WileyTitle/productCd-0764559036.html


Voltaire said:
Thanks Graham, that was helpful. I have tried coding too, unfortunately,
it only seems to work if I code each text label. Nothing seems to happen if
I do the following:
 
Graham R Seach said:
Voltaire,

You can't cancel the update like that. You must instead cancel the form's
update, then set the Cancel parameter.

Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim strMsg As String
strMsg = "Data has changed."
strMsg = strMsg & "@Do you wish to save the changes?"
strMsg = strMsg & "@Click Yes to Save or No to Discard changes."
If MsgBox(strMsg, vbQuestion + vbYesNo, "Save Record?") = vbYes Then
'do nothing
Else
Me.Undo
Cancel = True
End If
End Sub


Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia

Microsoft Access 2003 VBA Programmer's Reference
http://www.wiley.com/WileyCDA/WileyTitle/productCd-0764559036.html



it only seems to work if I code each text label. Nothing seems to happen if
I do the following:


Graham,
I found this post and it works like a charm. Thanks a ton.
digger27
 
This code works great for removing any change made, what if I want to keep
the original data. (I.e. Users will often mistakenly overtype information.
When they do this, I want them to have to confirm the change. If they select
"no" then the original information would stay the same)
 

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

Back
Top