473,834 Members | 1,799 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

I cant save data from form to table.(Urgent)

12 New Member
I'm creating a database for my company. Here we have errors form to calculate the errors done. The data entered in this form need to update into the errors table. This is my code but i'm getting error "Run-time error. Syntax error in INSERT INTO statement".

Private Sub CmdSave_Enter()

Dim strselect As String
Dim strinsert As String
Dim flag As Boolean
Dim temp As String
Dim msgval As Integer


flag = True


'Below query Selects the recordset as per the conditions
strselect = "Select * FROM Errors where Date = date() AND Sub-Process='" & txtSub.Value & "'"


'Below Query inserts the Review time as a new record
strinsert = "INSERT INTO Errors (Date,LoginID,S ub-Process, Incorrect Data) values (date(),'" & Lgn & "', '" & txtSub.Value & "','" & txt1.Value & "')"



'Setting connection with different tables

Set cn = Application.Cur rentProject.Con nection 'Setting connection to the table Review_Time
Set rs = New ADODB.Recordset 'Selecting the records from the Review_Time Table
Set rs2 = New ADODB.Recordset 'For updating and inserting the records in the Review_Time Table


On Error GoTo errorhandler


errorhandler:

If flag = True Then

rs2.Open strinsert, cn, adOpenForwardOn ly, adLockOptimisti c

MsgBox "Reviewed Volume Added"

End If

Hope someone can guide me.Thank you in advance.
Nov 28 '07 #1
3 1626
MikeTheBike
639 Recognized Expert Contributor
I'm creating a database for my company. Here we have errors form to calculate the errors done. The data entered in this form need to update into the errors table. This is my code but i'm getting error "Run-time error. Syntax error in INSERT INTO statement".

Private Sub CmdSave_Enter()

Dim strselect As String
Dim strinsert As String
Dim flag As Boolean
Dim temp As String
Dim msgval As Integer


flag = True


'Below query Selects the recordset as per the conditions
strselect = "Select * FROM Errors where Date = date() AND Sub-Process='" & txtSub.Value & "'"


'Below Query inserts the Review time as a new record
strinsert = "INSERT INTO Errors (Date,LoginID,S ub-Process, Incorrect Data) values (date(),'" & Lgn & "', '" & txtSub.Value & "','" & txt1.Value & "')"



'Setting connection with different tables

Set cn = Application.Cur rentProject.Con nection 'Setting connection to the table Review_Time
Set rs = New ADODB.Recordset 'Selecting the records from the Review_Time Table
Set rs2 = New ADODB.Recordset 'For updating and inserting the records in the Review_Time Table


On Error GoTo errorhandler


errorhandler:

If flag = True Then

rs2.Open strinsert, cn, adOpenForwardOn ly, adLockOptimisti c

MsgBox "Reviewed Volume Added"

End If

Hope someone can guide me.Thank you in advance.
Hi

I don't think you can "open" an ACTION query.

Try something like this

CurrentProject. Connection.Exec ute strinsert, ,adExecuteNoRec ords

??

MTB
Nov 28 '07 #2
abie16
12 New Member
Thanks for the immediate reply MTB but it still dont work.
Nov 28 '07 #3
MikeTheBike
639 Recognized Expert Contributor
Thanks for the immediate reply MTB but it still dont work.
OK, so do you have the same error ??

My only suggestion without more information would be to enclose all references to the Date FIELD in square brackets ie [Date].

Does the SELECT query work?

BTW don't use key words or function names for field/variable names, it might not end in tears, but it will probably give problems at some point (speaking from experience here - naughty boy!).

MTB
Nov 28 '07 #4

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

Similar topics

4
8978
by: Bruce Skamser | last post by:
I added a field to a table and when I go to the form to add a textbox control, I can't bind it to the field in the table. It doesn't come up in the list of fields in the control source dropdown. What can I be doing wrong?
0
2413
by: amrhi | last post by:
Hy Guys , Can anybody help me ? I try to make small web database in my unit. Some of fields have on change behaviour to get other data that automatically filled other text field. But when i try to hit "enter" after i fill text field , its automatically save data in my table database . I just want to save data after , i click "save" button. <?php include"session.php"; mb_http_input("iso-8859-1"); mb_http_output("iso-8859-1"); $tgl=$_POST;...
1
6132
by: QCLee | last post by:
Hello Sir, Im here again asking for help. I have a form and a subform relate to HVAC Windward Table. i have a SAVE button on the form that when clicked it saves data on the HVAC Windward Table but not in a subform. When manually inputing data into subform it saves by work order on the HVAC Windward Table in subdatasheet even if how many times i add data in one work order. Sir, Is it posible that when i clicked on the SAVE button in the form it...
3
7170
by: =?Utf-8?B?YzY3NjIyOA==?= | last post by:
Hi all, I have a question for you. I have a .csv file which has many lines of data. Each line has many data fields which are delimited by ",". Now I need to extract part of data from this file but save it as an excel file. The data in this excel file will be imported into an Access database. The
0
9799
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9649
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10224
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9338
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...
0
5629
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...
0
5799
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4428
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
3985
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3084
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.