Microsoft Access Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMicrosoft Access Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old April 21st, 2005, 09:27 PM
Andres Andres is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2005
Posts: 1 Andres User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 12 m 37 sec
Reputation Power: 0
Question Cancel Button

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

Reply With Quote
  #2  
Old May 17th, 2005, 03:51 PM
fliflo fliflo is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2005
Posts: 4 fliflo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 58 m 20 sec
Reputation Power: 0
where are u using strMsg3?

Reply With Quote
  #3  
Old May 18th, 2005, 09:29 AM
lwells lwells is offline
Contributing User
Dev Articles Novice (500 - 999 posts)
 
Join Date: Sep 2004
Posts: 632 lwells User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 21 h 59 m 38 sec
Reputation Power: 4
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

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMicrosoft Access Development > Cancel Button


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway