473,568 Members | 2,882 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 27046
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_Cli ck

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

DoCmd.DoMenuIte m acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

Exit_cmdSave_Cl ick:
Exit Sub

Err_cmdSave_Cli ck:
MsgBox Err.Description
Resume Exit_cmdSave_Cl ick

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
1462
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 http://www.codecomments.com ------------------------------------------------------------------------
4
2621
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
3723
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 another way of doing a messagebox, none of the existing ways will work with the code we have already written. Most all of the message box...
1
1179
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
10590
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 this System.Web.HttpContext.Current.Response.Write("<SCRIPT LANGUAGE=""JavaScript"">" & vbCrLf)...
3
3816
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
5596
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 button click?
0
1092
by: kayyum | last post by:
how to show message in asp.net in code behind for web page using C#
0
8117
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7660
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7962
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6275
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5217
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3651
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3631
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2101
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 we have to send another system
1
1207
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.