-
Oct 6th, 2018, 02:05 AM
#1
Thread Starter
New Member
Run Time 3134: Syntax Error in INSERT INTO statement
I really need help. I don't know what else to do I tried everything already and even restarted it but it keeps saying the damn thing. It's really important since i'm doing a database for a company. Please Help
Code:
Code:
Private Sub cmdAdd_Click()
Dim Query1 As String
Query1 = "INSERT INTO FranklinOffshore([Description],[SWL Tonne],[Inches],[Model],[Safety Factor],[Date/LPO],[Manufacturer],[Opening Stocks],[January],[February],[March],[April],[May],[June],[July],[August],[September],[October],[November],[December,[Total Used],[Available Balance],[Minimum Stock], FOQ/FOI, Comments)" & _
" VALUES ('" & Me!txtDescription _
& ",'" & Me!txtSWLTonne.Value _
& "','" & Me!txtInches.Value _
& "','" & Me!txtModel.Value _
& "','" & Me!txtSafetyFactor.Value _
& "','" & Me!txtDatelpo.Value _
& "','" & Me!txtManufacturer.Value _
& "','" & Me!txtOpeningstocks.Value _
& "','" & Me!txtJanuary.Value _
& "','" & Me!txtFebruary.Value _
& "','" & Me!txtMarch.Value _
& "','" & Me!txtApril.Value _
& "','" & Me!txtMay.Value _
& "','" & Me!txtJune.Value _
& "','" & Me!txtJuly.Value _
& "','" & Me!txtAugust.Value _
& "','" & Me!txtSeptember.Value _
& "','" & Me!txtOctober.Value _
& "','" & Me!txtNovember.Value _
& "','" & Me!txtDecember.Value _
& "','" & Me!txtTotalused.Value _
& "','" & Me!txtAvailablebalance.Value _
& "','" & Me!txtMinimumstock.Value _
& "','" & Me!txtFoqfoi.Value & "','" & Me!txtComment.Value & "');"
Debug.Print Query1
DoCmd.RunSQL Query1
End Sub
It keeps saying the same thing, please help
-
Oct 6th, 2018, 06:33 AM
#2
Re: Run Time 3134: Syntax Error in INSERT INTO statement
The error message is telling you that there's an error in your INSERT statement and, as far as I can tell, you haven't even bothered to look at that statement. You certainly haven't bothered to show it to us. It should be obvious that you need to actually look at the SQL code and make sure it is what you expect it to be. If you do that then the issue should be obvious too.
-
Oct 6th, 2018, 08:59 AM
#3
Re: Run Time 3134: Syntax Error in INSERT INTO statement
1) Three words: parameters, parameters, parameters
2) Although in this case parameters wouldn't solve this issue specifically, it would at least help narrow down where the problem might be.
3) Even once the problem is corrected (hint, look in your field names) there's still the issue with concatenating things together and sanitizing the data and potential SQL injection attacks.,
4) Review this for an example of why SQL injections are bad.
-tg
-
Oct 6th, 2018, 09:24 AM
#4
Re: Run Time 3134: Syntax Error in INSERT INTO statement
Originally Posted by techgnome
Although in this case parameters wouldn't solve this issue specifically
There are at least two issues there and using parameters would solve one of them. You probably missed it because it's hard to see and it's hard to see because the code is hard to read, which is one of the very reasons to use parameters in the first place.
-
Oct 6th, 2018, 05:37 PM
#5
Re: Run Time 3134: Syntax Error in INSERT INTO statement
kimaleah,
the most important line in your code is:
Debug.Print Query1
is the result really what you expect it to be ?
if you really want someone to help you:
show the result
do not put off till tomorrow what you can put off forever
-
Oct 8th, 2018, 05:12 AM
#6
Re: Run Time 3134: Syntax Error in INSERT INTO statement
Other comments aside this doesn't seem right:
[Minimum Stock], FOQ/FOI, Comments)
Please remember next time...elections matter!
-
Oct 8th, 2018, 05:53 AM
#7
Re: Run Time 3134: Syntax Error in INSERT INTO statement
This one too:
[December,[Total Used],
and this one:
('" & Me!txtDescription _
& ",'"
There's a single quote missing
Agree with tg: Parameters
Last edited by Zvoni; Tomorrow at 31:69 PM.
----------------------------------------------------------------------------------------
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------------------
People call me crazy because i'm jumping out of perfectly fine airplanes.
---------------------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|