473,387 Members | 1,606 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

not save data until click 'ok'

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, 113 views)
File Type: zip unbound.zip (28.9 KB, 125 views)
Dec 20 '10 #1
3 2167
beacon
579 512MB
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
thank youuuuuuuu
Dec 21 '10 #3
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
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...
1
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
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...
1
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...
0
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...
2
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...
2
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...
3
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...
1
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...
0
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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...

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.