473,466 Members | 1,326 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Syntax error on insert statement

5 New Member
Hi Folks. I have a simple insert statement only four fields. The last field "Table" is the problem child. IF I take it out and the associated value "Me.txtTempTab" the insert statement works. Image of code also attached. Any assistance would be greatly appreciated. Thank you in advance...
Expand|Select|Wrap|Line Numbers
  1. DoCmd.RunSQL "INSERT INTO tblScrBldSched " & _
  2. "( OrderNo, Tech, SchedDate, Table )" & _
  3. "VALUES ('" & Me.cmbSTBT1A.Column(0) & "' ," & _
  4. " '" & Me.cmbScrTechT1A.Column(0) & "' ," & _
  5. " '" & Me.txtSchedDate & "' ," & _
  6. " '" & Me.txtTempTab & "' );"
  7.  
  8.  
Attached Images
File Type: jpg insert code.JPG (26.7 KB, 76 views)
Sep 4 '20 #1

✓ answered by ADezii

First, try a couple of minor adjustments:
Expand|Select|Wrap|Line Numbers
  1. DoCmd.RunSQL "INSERT INTO tblScrBldSched " & _
  2.              "([OrderNo], [Tech], [SchedDate], [Table])" & _
  3.              " VALUES ('" & Me.cmbSTBT1A.Column(0) & "' ," & _
  4.              "'" & Me.cmbScrTechT1A.Column(0) & "' ," & _
  5.              "'" & Me.txtSchedDate & "' ," & _
  6.              "'" & Me.txtTempTab & "');"

3 2357
ADezii
8,834 Recognized Expert Expert
First, try a couple of minor adjustments:
Expand|Select|Wrap|Line Numbers
  1. DoCmd.RunSQL "INSERT INTO tblScrBldSched " & _
  2.              "([OrderNo], [Tech], [SchedDate], [Table])" & _
  3.              " VALUES ('" & Me.cmbSTBT1A.Column(0) & "' ," & _
  4.              "'" & Me.cmbScrTechT1A.Column(0) & "' ," & _
  5.              "'" & Me.txtSchedDate & "' ," & _
  6.              "'" & Me.txtTempTab & "');"
Sep 4 '20 #2
rcsmith0712
5 New Member
Thanks ADezii. That worked! Though I'm not sure why the brackets are needed in this case. Can you help me understand why?
Sep 5 '20 #3
cactusdata
214 Recognized Expert New Member
The brackets are only needed for reserved words and names with spaces or weird characters.
Also, a date value should be inserted as a string expression for the date value, not as text, thus:

Expand|Select|Wrap|Line Numbers
  1. DoCmd.RunSQL "INSERT INTO tblScrBldSched " & _
  2. "( OrderNo, Tech, SchedDate, [Table] ) " & _
  3. "VALUES ('" & Me.cmbSTBT1A.Column(0) & "', " & _
  4. "'" & Me.cmbScrTechT1A.Column(0) & "', " & _
  5. "#" & Format(Me!txtSchedDate.Value, "yyyy\/mm\/dd") & "#, " & _
  6. "'" & Me.txtTempTab & "');"
Sep 5 '20 #4

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

Similar topics

2
by: Tim::.. | last post by:
Can someone please tell me why I keep getting the following error from the code below! Error: INSERT statement conflicted with COLUMN FOREIGN KEY constraint...
3
by: jinhy82 | last post by:
Hi! I am currently creating a Registration form which contained: UserID Password, FirstName and LastName. These details would be inserted into Ms Access when I click submi button. But I...
9
by: Ed Pisa | last post by:
Hello, I have been working with this problem now for several days. I can delete and Update my data but I can not get it to insert a new record. I receive the syntax error insert into. I am not...
0
by: Ed Pisa | last post by:
Hello, I have been working with this problem now for several days. I can delete and Update my data but I can not get it to insert a new record. I receive the syntax error insert into. I am not...
2
by: RameshKumar | last post by:
'Register User Form Imports System.Data.OleDb Public Class RegisterUser ‘ Variables Decleration Public Con As OleDbConnection Public Cmd As OleDbCommand Public Dr As...
9
by: NikArt | last post by:
I get syntax errors while trying to copy all data from a query into a table using INSERT INTO and SELECT. Here are the lines: INSERT INTO LoadTBTemp])] SELECT Data1 FROM LoadTB ...
4
by: sonurathore | last post by:
pls help me this code error geting for syntax error insert into statement pls check it string SqlString = "INSERT INTO CUSTOMER...
1
by: Olabode | last post by:
hello guys I am new here and in programing I have this program that I am designing am using Visual studio 2010 and ms access 2010. am using ms access as a data base i have successfully designed...
3
by: asyrofifarel | last post by:
#include<stdio.h> #include<conio.h> main() { int hp,jp,ap,jb,ht float ht; printf("-->LankBuana Audio System<--"); printf("\n======================"); printf("\nMASUKAN NAMA PEMBELIAN = ");...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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
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
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...
0
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
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,...
0
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...
0
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
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...

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.