Access 2010 Vba Runtime Error 3134
Contents |
Social Groups Pictures & Albums Members List Calendar Search Forums Show Threads Show Posts Tag Search Advanced Search Find All Thanked Posts Go to Page... Thread Tools Rate Thread Display 3134 error access Modes 03-01-2010, 12:42 PM #1 AndyCabbages Registered User Join Date: Feb 2010 run-time error '3134' syntax error in insert into statement Posts: 74 Thanks: 0 Thanked 0 Times in 0 Posts Run-time error '3134' I am getting the following error: Run-time error
Runtime Error 3075
'3134' Syntax error in INSERT INTO statement This is the piece of code I am directed to: Private Function addSuite() If suiteName = "" Or Description = "" Then MsgBox "Please enter a name and description for this suite!" Else If equip1 = "" Or equip2 = "" Then MsgBox "Please make sure that the first two items are selected!" Else If DayPrice = "" Or WeekPrice = "" Then MsgBox "Make sure you have entered a day price and a week price for this suite!" Else addSQL = "INSERT INTO suites (Name, Description, Day_Price, Week_Price, Item1, Item2, Item3, Item4, Item5, Item6, Insurance_Value, Weight) Values ('" & suiteName & "', '" & Description & "', " & DayPrice & ", " & WeekPrice & ", '" & equip1 & "', '" & equip2 & "', '" & equip3 & "', '" & equip4 & "', '" & equip5 & "', '" & equip6 & "', '" & IValue & "', '" & GrossWeight & "')" DoCmd.RunSQL (addSQL) DoCmd.Close End If End If End If End Function The debugger suggests that the error is on the line: DoCmd.RunSQL (addSQL) Any suggestions? I really dont know much about visual basic and cant make such sense of the above piece of code. Andy AndyCabbages View Public Profile Find More Posts by AndyCabbages 03-01-2010, 12:44 PM #2 SOS Registered Lunatic Join Date: Aug 2008 Location: Somewhere between here and there Posts: 3,520 Thanks: 2 Thanked 54 Times in 52 Posts Re: Run-time error '3134' Well, one thing jumps out at me right away. You have a field name (NAME) which is an Access Reserved Word and that is not good. You WILL have to use square brackets around it like [Name] EVERY PLACE you use it. I would suggest renaming that field and going on as NAM
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up 3134 http://www.access-programmers.co.uk/forums/showthread.php?t=189178 run time error on Insert into statement up vote 1 down vote favorite I am trying to write a form to insert data into multiple tables within a single database. I know you can't do that through a single Insert into statement so I read that I should create a transaction and include multiple Insert statements. I keep getting 3134 run time error http://stackoverflow.com/questions/19841012/3134-run-time-error-on-insert-into-statement on my second insert statement. Here is the code: Private Sub cmdAdd_Click() DBEngine.BeginTrans CurrentDb.Execute "INSERT into Names(StudentId, FirstName, MiddleName, LastName) VALUES (" & Me.txtStudentId & ",'" & _ Me.txtFirstName & "','" & Me.txtMiddleName & "','" & Me.txtLastName & "')" CurrentDb.Execute "INSERT into Homeroom(StudentId, Grade, Homeroom_Primary, Name-Homeroom_Primary_Teacher) " & _ "VALUES (" & Me.txtStudentId & ",'" & Me.txtGrade & "','" & Me.txtHomeroom & "','" & Me.txtTeacher & "')" CurrentDb.Execute "INSERT into [Ridgeview Math](StudentId, ExportGrade, DateTaken, SS, PR) VALUES (" & _ Me.txtStudentId & ",'" & Me.txtGrade & "',#" & Me.txtMathdate & "#,'" & Me.txtMathSS & "','" & Me.txtMathPR & "')" CurrentDb.Execute "INSERT into [Ridgeview Reading](StudentId, ExportGrade, DateTaken, RSS, RPR, RIRL) " & _ "VALUES (" & Me.txtStudentId & "','" & Me.txtGrade & "',#" & Me.txtReadingdate & "#,'" & Me.txtReadingSS & "','" & _ Me.txtReadingPR & "','" & Me.txtReadingIRL & "')" CurrentDb.Execute "INSERT into CompassGroup(StudentId, CompassGroup) VALUES (" & Me.txtStudentId & _ "," & Me.txtCompassGroup & ")" DBEngine.CommitTrans End Sub Am I doing something wrong with the nested Insert statements? This is all tied to a form where the variables are created and the data is entered. The first Insert stateme
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us http://stackoverflow.com/questions/27659251/runtime-error-3134-syntax-error-in-insert-into-statement Learn more about Stack Overflow the company Business Learn more about hiring developers http://www.mrexcel.com/forum/microsoft-access/753645-run-time-error-3134-syntax-error-insert-into-statement.html or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Runtime Error 3134 - Syntax Error in INSERT runtime error INTO Statement up vote 0 down vote favorite I'm trying to fix it about hour but it's not work Please help me :( CurrentDb.Execute "INSERT INTO match_day( home_team, away_team, date, time, home_score, away_score, stadium) " & _ " VALUES('" & Me.textHT & "','" & Me.textAT & "',#" & Me.textDATE & "#,#" & Me.textTime & "#," & Me.textHS & "," & Me.textAS & ",'" & Me.textSTD & ",')" access 2010 vba ms-access share|improve this question asked Dec 26 '14 at 16:03 user3071071 32 add a comment| 2 Answers 2 active oldest votes up vote 3 down vote Are the fields for date and time considered reserved words and should be wrapped in brackets or ticks to qualify it as the column name... ..., [date], [time], ... But I think it is most likely the trailing final comma before your final closing ) of the inserted values making it look like it wants another field to be inserted. Me.textSTD & ",')" change to Me.textSTD & "')" share|improve this answer answered Dec 26 '14 at 16:06 DRapp 32.5k74597 Not to mention it's vulnerable to SQL injection. –Ben McIntyre Dec 29 '14 at 9:33 add a comment| up vote 0 down vote I ran into a similar error - thanks to this post I realised that I had used a reserved name "note" in a table ( instead of "notes"). StrSQL = "INSERT INTO option_notes ( OPTION_ID , USER_ID , [NOTE] ) VALUES ( " & currID & " , " & currUserID & " , '" & currNote & "' ) ; " CurrentDb.Execute StrSQL I ended up changing
Forums Microsoft Access Run-Time Error 3134 - Syntax Error in Insert Into Statement Results 1 to 5 of 5 Run-Time Error 3134 - Syntax Error in Insert Into StatementThis is a discussion on Run-Time Error 3134 - Syntax Error in Insert Into Statement within the Microsoft Access forums, part of the Question Forums category; Hi - I have an Insert Into Statement in my VBA code and I keep getting a run-time error 3134. ... LinkBack LinkBack URL About LinkBacks Bookmark & Share Digg this Thread!Add Thread to del.icio.usBookmark in TechnoratiTweet this thread Thread Tools Show Printable Version Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode Jan 28th, 2014,02:09 PM #1 davidb88 Board Regular Join Date Sep 2013 Posts 75 Run-Time Error 3134 - Syntax Error in Insert Into Statement Hi - I have an Insert Into Statement in my VBA code and I keep getting a run-time error 3134. I know there are a number of posts about this type of problem and I have tried all of the solutions I have found but nothing seems to work for this particular string. If someone sees the issue, can you please point it out? Thanks. Code: strSQL = "INSERT INTO tblPDcalc ([Month End], [Loan Type], [FICO Band], [r1PD], [r2PD], [r3PD], [r4PD], [r5PD], " _ & "SELECT (#" & modeldate & "#, '1st Mtg', '1', " _ & " " & r1PD & ", " & r2PD & ", " & r3PD & ", " & r4PD & ", " & r5PD & ");" DoCmd.RunSQL (strSQL) Share Share this post on Digg Del.icio.us Technorati Twitter Reply With Quote Jan 28th, 2014,02:35 PM #2 mole999 Moderator Join Date Oct 2004 Location UK Posts 6,758 Re: Run-Time Error 3134 - Syntax Error in Insert Into Statement double speech marks on beginning of line three look suspicious to me Share Share this post on Digg Del.icio.us Technorati Twitter Yes I know there are better ways to do it. I just wish I knew them. - 2003, 2007, 2010, 2013 & 2016 I wear my ignorance openly, excel is not my chosen career, its a means to an endsPosting Guidelines Want to post well laid out questions and answers Translate Excel Versions Code: [CODE ]Put Your Code[/ CODE] Settings > General Settings (on the left) scroll to the bottom, > Miscellaneous Options > Use ENHANCEDX-Posting Guidelines Rule 13 Reply With Quote Jan 28th, 2014,02:39 PM #3 Norie Board Regular Join Date Apr 2004 Location Stir