|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hi,
On closing my form on my database I would like the user to have an option of deleting the record or saving it. I understand to delete the record this should work: DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70. Unfortunately it's not deleting the record. Any suggestions as to how to fix this? Here's the code I have. Thank you... Private Sub Form_Close() Dim strMsg1 As String Dim strMsg2 As String Dim strMsg3 As String strMsg1 = strMsg1 & "Data has changed. " strMsg2 = strMsg1 & "Do you wish to save changes? " If MsgBox(strMsg2, vbQuestion + vbYesNo, "Save Record?") = vbYes Then 'do nothing Else DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70 End If End Sub |
|
#2
|
|||
|
|||
|
where are u using strMsg3?
|
|
#3
|
|||
|
|||
|
Instead of using the Close Event for your form place the code in the Before UpDate Event as in this example:
Private Sub Form_BeforeUpdate(Cancel As Integer) Dim strMsg As String strMsg = "Data Has Changed" & vbCrLf & _ "Do You Want to Save Changes?" If MsgBox(strMsg, vbQuestion + vbYesNo, "Save Record") = vbNo Then DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70 End If End Sub See if this solves what you were wanting. lwells |
![]() |
| Viewing: Dev Articles Community Forums > Databases > Microsoft Access Development > Cancel Button |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|