473,661 Members | 2,432 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

not save data until click 'ok'

4 New Member
hi
I have a problem
I want not save data until click 'ok'
and Do not save anything when click 'cancel'
in form and subform

i'm find two file (in attachments)
but incorrect

please help me
Attached Files
File Type: zip DemoSaveA2000.zip (28.9 KB, 114 views)
File Type: zip unbound.zip (28.9 KB, 126 views)
Dec 20 '10 #1
3 2174
beacon
579 Contributor
I always create an unbound form and use the SQL INSERT INTO query to put the data from the fields in my form into the table. I add the INSERT query to the Click event of a command button, usually called 'Save' or 'Submit'.

Here's an example of a Click event with an INSERT query:
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdSave_Click()
  2.  
  3.      Dim strSQL As String
  4.  
  5.      'Assuming that TableFields are fields in your table
  6.      'Assuming that FormFields are fields on your form
  7.      'Assumes that FormField1 is numeric, FormField2 is a string, and FormField3 is a date
  8.      strSQL = "INSERT INTO YourTable([TableField1], [TableField2], [TableField3]) VALUES (" & Me.FormField1 & ", '" & Me.FormField2 & ", #" & Me.FormField3 & "#);"
  9.  
  10.      Msgbox "Save Complete"
  11.  
  12. End Sub
  13.  
To cancel, just create a command button similar to the above, except instead of using the SQL query, just use the following:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Cancel_Click()
  2.  
  3.      Dim userSelection
  4.  
  5.      userSelection = MsgBox("Are you sure you want to close the form without saving?", vbExclamation + vbYesNo, "Cancel")
  6.  
  7.     If userSelection = vbYes Then
  8.         DoCmd.Close acForm, Me.Name
  9.         MsgBox "You will now be returned to the Main Menu", vbOKOnly + vbInformation, "Return to Main Menu"
  10.         DoCmd.OpenForm "Switchboard"
  11.     ElseIf userSelection = vbNo Then
  12.         Exit Sub
  13.     Else
  14.         MsgBox "An error has occurred. You will be returned to the form.", vbCritical + vbOKOnly, "Error"
  15.         Exit Sub
  16.     End If
  17. End Sub
  18.  
Hope this helps,
beacon
Dec 20 '10 #2
stabesh
4 New Member
thank youuuuuuuu
Dec 21 '10 #3
stabesh
4 New Member
hi
I'm find it

Is exist any better way ?

thanks
Attached Files
File Type: zip DemoSaveA2000.zip (52.6 KB, 124 views)
Dec 21 '10 #4

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

Similar topics

2
2680
by: Danny Wang | last post by:
HI, I have a dialog (window) with a drop-down list and an OK button. When user clicks the drop-down list, the app need to do some calculation and validation, so I put an Text_on_change event on the drop-down. When click OK the dialog should be closed; however, if the user already clicked the drop-down, he needs to click OK button twice to close the window. After a little research I found out the once the focus is moved out the drop-down...
1
3631
by: JJ | last post by:
Hi All, How in ASP.NET, from PopUp window: 1) - save Data in Database; and after 2) a) - Reload the opener window b) -close PopYp window. Note:
3
2394
by: Darius | last post by:
Hello, there is an NMEAParserDemo application written in VC++ avaliable for download from http://www.visualgps.net/Papers/NMEAParser/NMEAParserDemo%20Project.zip. Source code in VC++ is provided, unfortunately this application features no logging option. My intention is to add data logging option to let me read processed lat, lon, alt, time data on-line in another application.
1
2854
by: freeskier | last post by:
Hello, I would like to make a data entry form that does not save values until "save" is clicked. This is because sometimes the form may be opened by accident and it automatically creates a blank entry. I have read that this should be done in the before update event of the form. Would this be easier to do if the form were unbound? I am just looking for any suggestions to the easiest solution. Thanks for your time on this newb question
0
1892
by: Rob | last post by:
I have a Webservice written in C# that provides data to both a web browser through ASP.net and to a VC++ client. I have been able to retrieve data from SQLServer and passing to my C++ client as XML without a problem using the SqlDataAdaptor and the DataSet. I am a bit confused how to save data to SQL Server from my client. I figured if I could create a DataSet, I could save it to the database. I wrote a WebMethod that takes a string...
2
1451
by: vivekshrivastava51 | last post by:
Hi, i m making on web project using asp.net , C#.net in visual studio 2003 using sql server i have to save data using excel or csv file to database by what can i do if any one have coding pls send me its urjent.. thanks.
2
1619
by: susisri | last post by:
Hi, if any one please clear my doubt. i created one form in vb.it contains(empid,othertsk,descrption....etc) if any user fill these details click ok then these details are saved into the Excel file. can anyone tell how to write the code for above form?
3
5236
by: STEPHENSS | last post by:
Hi, I have a crystal report that has many subreports over many pages and Iam getting the following error Unable to save data with report, the save data is incomplete generate the saved data Yes or no. If i go to the last page and try save data I get no error message. Need Help
1
2609
by: TonyJ | last post by:
Hello! I'm using VS2005. I'm looking at ADO.NET and have found some test tutorial solution on microsoft MSDN. The one that I'm looking at now is called Walkthrough: Saving Data to a Database (Single Table) I have followed the walkthrought exectly but it doesn't work as expected.
0
1908
by: e_spork | last post by:
I am using Page.ClientScript.RegisterStartupScript to throw up a Javascript alert box. When I click OK on the alert box, all the controls on my page disappear and I don't understand why. I can View Source in the browser and see all the controls so I know they are there, yet they vanish once I click OK. This is happening on a Content page. The browser is IE 6.0.2900 and I'm running it inside of Visual Studio 2005. My master page...
0
8851
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8754
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8542
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
7362
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6181
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5650
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4177
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2760
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
2
1740
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.