syntax error in INSERT INTO statement, checked with space already - ms-access

I was trying to run this following SQL through vba, however, it keeps telling there is a syntax error in INSERT INTO statement. Can anyone help with it? Thanks a lot.
Dim strTemp2 As String
strTemp2 = "INSERT INTO tblPartDocs(idsPartDocID, idsScanID, intPartNum, strShopOrder/LotBatchID, dtmDateOfWork) VALUES " _
& "('" & Me.tboScanID & "','" & Me.tboScanID & "','" & Me.tboPartNumber & "','" & Me.tboShop & "','" & Me.tboDateOfWork & "');"
DoCmd.RunSQL strTemp2

I think problem is here
"strShopOrder/LotBatchI"
You are require to provide comma instead of forward slash

Related

Microsoft Access form submission

I'm new to Access and have a few questions. To start off, after watching some tutorials and researching, I keep getting a Syntax error on my submission button. I am just trying to write to the database from the form. Here is my error.
Private Sub btn_Add_Click()
CurrentDb.Execute "INSERT INTO IPA_Raw_Data(Date, Auditor) " _
" VALUES(" & Me.txt_Date & ",'" & Me.txt_Name & "')"
btn_Clear_Click
End Sub
I'm sure it's something simple. Just new to this. Thanks!
Date is a reserved word in SQL, and your syntax needs a brush-up. So:
Private Sub btn_Add_Click()
CurrentDb.Execute _
"INSERT INTO IPA_Raw_Data([Date], Auditor) " & _
"VALUES (#" & Format(Me!txt_Date.Value, "yyyy\/mm\/dd") & "#,'" & Me!txt_Name.Value & "')"
End Sub

Run-time error '3075': "syntax error (missing operator) in certain query expressions"

Private Sub cmdSendOrder_Click()
'add data to table
CurrentDb.Execute "INSERT INTO OrderSummary(OrderNumber, SupplierCode, DateOrdered, EmployeeNumber) " & _
" VALUES (" & Me.txtOrderNumber & "','" & Me.cboSupplierCodeO & "','" & Me.txtDateO & "','" & Me.txtEmployeeO & "') "
'refresh data on list of form
OrderSummarySub.Form.Requery
End Sub
My code gets a run-time error saying it has a syntax error (missing operator) in certain query expressions. I'm pretty sure the names I put above were correct.
You are missing your first single quote before Me.txtOrderNumber:
"INSERT INTO OrderSummary(...) VALUES ('" & ...

Syntax error while creating query in code

comm = "INSERT INTO CUST_DETAILS (cust_ID,cust_name,Address,Email-id,Phone_no)"
+ "values ('" & txtID.Text & "','" & txtName.Text & "','"
& txtAdd.Text & "','" & txtEmail.Text & "','" & txtPhone.Text & "')"
What is the error?
VB6 does not automatically know that a line continues after a line break. If you do not use the line continuation character VB6 sees the end of the line as the end of the statement, and the next line as a new statement. So the second and third lines are syntactically incorrect. To fix it add a single space followed by an underscore after the first and second lines to tell the VB6 that the line continues on the next line.
comm = "INSERT INTO CUST_DETAILS (cust_ID,cust_name,Address,Email-id,Phone_no)" _
& "values ('" & txtID.Text & "','" & txtName.Text & "','" _
& txtAdd.Text & "','" & txtEmail.Text & "','" & txtPhone.Text & "')"
MSDN reference here
Also please note I replaced your "+" which will concatenate a string, but is bad practice with an ampersand.

Inssert Statment, Values not Coded correctly

Complete VBA newb...trying to enter some simple data into a simple table from an access form.
I used a youtube video and attempted to modify the code for my use, however I can get seem to get passed errors.
Here is the code mapped to the button that I am using to enter in the data
Private Sub Command0_Click()
'add data to table
CurrentDb.Execute "INSERT INTO EmpLunchTBL (FullName, ManName, TuesOrder, ThursOrder, PayType)" & _
"VALUES (" ' & Me.txtName & ",'" & Me.txtMS & "','" & Me.cboTues & "','" & Me.cboThurs & "','" & Me.cboPaytype & "')"
End Sub
Pretty Straight forward, I know the issue lies somewhere within my values area...but again total newb...
Thank you!
I think the "VALUES (" ' is the problem. Try this:
Private Sub Command0_Click()
'add data to table
Debug.Print "INSERT INTO EmpLunchTBL (FullName, ManName, TuesOrder, ThursOrder, PayType)" & _
"VALUES ('" & Me.txtName & "','" & Me.txtMS & "','" & Me.cboTues & "','" & Me.cboThurs & "','" & Me.cboPaytype & "')"
End Sub
Edit: Another single quote was missing.

showing run time error 3134 in access from

it is giving me an run time error 3134 syntax error in insert into statement while clicking on the control.
Private Sub CmdAddNew_Click()
'add data to table
CurrentDb.Execute "INSERT INTO tblemployee(,firstname,lastname,Address,city)" & _
"VALUES('" & Me.txtfirstname & "','" & Me.txtlastname & "','" & Me.txtaddress & "','" & Me.txtcity & "')"
tblemployee(,firstname
Extra comma here?