473,503 Members | 1,692 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

Daniel B
33 New Member
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 27010
yarbrough40
320 Contributor
Should be fairly easy. What have you tried so far?
Jan 14 '11 #2
Daniel B
33 New Member
well I am not very experienced with VB so I'm kind of lost.
Jan 14 '11 #3
yarbrough40
320 Contributor
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
Daniel B
33 New Member
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
yarbrough40
320 Contributor
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()
  2.  
  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
Daniel B
33 New Member
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_cmdSave_Click:
Exit Sub

Err_cmdSave_Click:
MsgBox Err.Description
Resume Exit_cmdSave_Click

End If
End Sub
Jan 14 '11 #7
yarbrough40
320 Contributor
Looks fine to me. is it working?
Jan 14 '11 #8
Daniel B
33 New Member
Yup it's working perfect. Except when I click Save, how do you get the form to close?
Jan 14 '11 #9
Daniel B
33 New Member
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

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

Similar topics

2
1454
by: craymel | last post by:
Hi , can i know how can i make that the page show only TOP 5 record in the database ? -- craymel ------------------------------------------------------------------------ Posted via...
4
2618
by: news.online.no | last post by:
In a query, I need too be able to show if a parent record has a child record. Using the query in a combo box too select record in a form. Thanks :)
2
3715
by: Mike Moore | last post by:
asp.net app - How do you get Java-side code to communicate with server-side code? I have tried numerous ways and examples, but have been unsuccessful. Therefore, unless I get real lucky and find...
1
1171
by: Mike Moore | last post by:
We have a custom validator that should validate when there is a duplciate record, but the problem is that the show message box doesn't display. Why suggestions as to why?
4
10579
by: bnob | last post by:
In a Button clik event I have this code at the end of the event Response.Redirect("Page.aspx") But in this event I must show a message before redirect to the Page.aspx. I use to show Message...
3
3810
by: ad | last post by:
I want user can confirm before delete records ? How can I show a confirm dialog when users press a button?
3
5594
by: ad | last post by:
I can only use the OnClientClick event of a button to show a confirm dialog like: OnClientClick="return confirm('Are you sure?');" Can we show the confirm dialog by progrm, net triggered by a...
0
1080
by: kayyum | last post by:
how to show message in asp.net in code behind for web page using C#
0
7199
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7074
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7273
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7322
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6982
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7451
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4667
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1501
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
731
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.