469,315 Members | 1,795 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,315 developers. It's quick & easy.

How to show a message box to confirm saving a new record?

Daniel B
I have a save button on my form that, on click, saves the new record, but I would like to have a message box appear and ask if the user is sure they want to save (yes/ok or no/cancel). Then once the user has chosen yes/ok to save the new record, the form should close.

Any suggestions are appreciated!

Dan B.
Jan 14 '11 #1
9 24940
320 100+
Should be fairly easy. What have you tried so far?
Jan 14 '11 #2
well I am not very experienced with VB so I'm kind of lost.
Jan 14 '11 #3
320 100+
ok no problem... you say that your button is saving a record in a table. Are you writing this in an Event Procedure (using code) or did you simply use the wizzard when you added the button to call a record save?

Are you familiar with writing VBA code in event procedures?
Jan 14 '11 #4
I did it in an event procedure, but I got help on that part too. Well I understand how some of it works, but I'm not familiar with writing VBA code.
Jan 14 '11 #5
320 100+
ok well what you want to use is a message box with the buttons you need. It should look something like this:
Expand|Select|Wrap|Line Numbers
  1. Private Sub MyCommandButton_Click()
  3. If MsgBox("Are You Sure You Want to save ?", vbOKCancel) = vbOK Then
  4. ' OK was clicked....write code here to save your record
  5. Else
  6. ' Cancel was clicked...write code here to do something else
  7. End If
  8. End Sub
If you still need help, just show me the actual code you have now that saves your record I can help you further.
Jan 14 '11 #6
This is what I have..

Private Sub cmdSave_Click()
On Error GoTo Err_cmdSave_Click

If MsgBox("Are you sure you want to save?", vbOKCanecl) = vbOK Then

DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

Exit Sub

MsgBox Err.Description
Resume Exit_cmdSave_Click

End If
End Sub
Jan 14 '11 #7
320 100+
Looks fine to me. is it working?
Jan 14 '11 #8
Yup it's working perfect. Except when I click Save, how do you get the form to close?
Jan 14 '11 #9
Actually I figured it out. Thank you so much for taking the time to help me, I really appreciate it!

Dan B.
Jan 14 '11 #10

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by Mike Moore | last post: by
1 post views Thread by Mike Moore | last post: by
3 posts views Thread by ad | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Geralt96 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.