Access 2010 Runtime Error 3134
Contents |
Syntax Error in INSERT INTO Statement If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above 3134 error access to proceed. To start viewing messages, select the forum that you want to visit from
Run-time Error '3134' Syntax Error In Insert Into Statement
the selection below. Results 1 to 4 of 4 Thread: [RESOLVED] Runtime Error 3134 - Syntax Error in INSERT INTO Statement Tweet runtime error 3075 Thread Tools Show Printable Version Subscribe to this Thread… Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode May 13th, 2011,10:14 AM #1 Wiggz View Profile View Forum Posts Thread Starter New Member Join Date May 2011 Posts 12 [RESOLVED] Runtime Error 3134 - Syntax Error in INSERT INTO Statement Hello all, First time poster here. I have worked with VB6 in the past but am a little rusty. My employer gave me a database (already partially constructed) to work on in my free time. I am using MS Access 2007. My current issue is with the following code which executes on a button click on an unbound form: Code: Private Sub Command44_Click() Dim query1 As String query1 = "INSERT INTO User (Last Name, First Name, User name, Location, " & _ "Staff ID, Email1, Email2, Nickname, Address, City, State, Zip, Home Phone, " & _ "Cell Phone, Notes) VALUES ('" & Me!LastName.Value & "', '" & Me!FirstName.Value _ & "', '" & Me!Username.Value & "', '" & Me!Location.Value & "', '" & Me!StaffID.Value _ & "', '" & Me!Email1.Value & "', '" & Me!Email2.Value & "', '" & Me!Nickname.Value _ & "', '" & Me!Address.Value & "', '" & Me!City.Value & "', '" & Me!State.Value _ & "', " & Me!Zip.Value & ", " & Me!HomePhone.Value & ", " & Me!CellPhone.Value _ & ", '" & Me!Notes.Value & "');" Debug.Print query1 DoCmd.RunSQL query1 End Sub The results of the Debug.Print statement are: Code: INSERT INTO User (Last Name, First Name, User name, Location, Staff ID, Email1, Email2, Nickname, Address, City, State, Zip, Home Phone, Cell Phone, Notes) VALUES ('Smith', 'John', 'jsmith', 'MHS', 'JK38471', 'jsmith@blah.com', 'smithj@blargh.edu', 'Jonny', '465 Anywhere St.', 'Anytown', 'AK', 48654, 4564564565, 6548651388, 'Notes about his man…'); Upon clicking the button I am getting the error in the title: Runtime Error 3134 - Syntax Error in INSERT INTO Statement I have looked around and have been unable to find an
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 Runtime Error 3134 - Syntax Error http://www.vbforums.com/showthread.php?649836-RESOLVED-Runtime-Error-3134-Syntax-Error-in-INSERT-INTO-Statement in INSERT 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 & ",'" & http://stackoverflow.com/questions/27659251/runtime-error-3134-syntax-error-in-insert-into-statement Me.textSTD & ",')" 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 & "' ) ; " Curr
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 http://stackoverflow.com/questions/29342031/runtime-error-3134-syntax-error-in-insert-into-statement-ms-access-vba about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users https://social.msdn.microsoft.com/Forums/office/en-US/05908f32-2ba3-40d8-ab95-e7e36e9291f2/runtime-error-3134-syntax-error-in-insert-into-statement?forum=accessdev 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 INTO Statement (MS Access VBA) up vote 0 down vote favorite I changed the input on the data table and runtime error added the "from" and "to" to the table and the query, however now I get the error Runtime Error 3134 - Syntax Error in INSERT INTO Statement My statement: db.Execute "INSERT INTO Temp ( LoadNum, ReferenceNum, ActivityDate, Appointment, From, To, OriginCity, OriginCountry, DestinationCity, DestinationCountry, [Carrier Name], [Load Status] ) " _ & "SELECT Data.LoadNum, Data.ReferenceNum, Data.ActivityDate, Data.Appointment, Data.From, Data.To, Data.OriginCity, Data.OriginCountry, Data.DestinationCity, Data.DestinationCountry, Data.[Carrier Name], Data.[Load Status] " _ & "FROM Data " _ & "WHERE [Data].[CarrierCode]='" access 2010 runtime & cNum & "';" I've been staring at this for a while, but i cannot find the error. Does anyone have an idea? vba ms-access share|improve this question edited Mar 30 '15 at 9:18 Jean-Francois Corbett 23.9k1678113 asked Mar 30 '15 at 8:56 eelc016 1 Can you take a moment to apply style formatting to your codes? stackoverflow.com/editing-help –James Wong Mar 30 '15 at 9:03 Syntax Error is usually just a typo in your query. I have had this probem many times. The best procedure is to start with a very simple version of the query and then adding the other parts step by step while trying it out everytime. This way you can pinpoint the probelematic part. –mernerp Mar 30 '15 at 9:20 add a comment| 1 Answer 1 active oldest votes up vote 0 down vote You probably need wrap at least these reserved words in brackets: .., [From], [To], .. Full list: Reserved words in Access SQL share|improve this answer edited Mar 30 '15 at 13:09 answered Mar 30 '15 at 9:32 Gustav 12.3k21026 This was exactly the issue! Is there an overview online to know what the reserved words within VBA are? –eelc016 Mar 30 '15 at 11:07 Yes. Just bing for it. –Gustav Mar 30 '15 at 13:09 add a comment| Your Answer draft
soon) Ruby (coming soon) Getting Started Code Samples Resources Patterns and Practices App Registration Tool Events Podcasts Training API Sandbox Videos Documentation Office Add-ins Office Add-in Availability Office Add-ins Changelog Microsoft Graph API Office 365 Connectors Office 365 REST APIs SharePoint Add-ins Office UI Fabric Submit to the Office Store All Documentation https://www.yammer.com/ http://feeds.feedburner.com/office/fmNx Ask a question Quick access Forums home Browse forums users FAQ Search related threads Remove From My Forums Answered by: Run-time error 3134 - Syntax error in Insert Into statement Microsoft Office for Developers > Access for Developers Question 0 Sign in to vote Dim StrSQL As String StrSQL = "" StrSQL = "INSERT INTO tbl_records FacilityLocation VALUES 'Napa' " Debug.Print StrSQL DoCmd.RunSQL (StrSQL) I cannot for the life of me figure out why this is giving me this error. The field name is fine and the table name is correct. What is going on here? Tuesday, November 09, 2010 12:54 AM Reply | Quote Answers 0 Sign in to vote Chrsitina Glabas wrote: Dim StrSQL As String StrSQL = "" StrSQL = "INSERT INTO tbl_records FacilityLocation VALUES 'Napa' " StrSQL = "INSERT INTO tbl_records( FacilityLocation) VALUES( 'Napa' ) " Mind the parentheses. Peter Doering [MVP Access] Marked as answer by VanderghastModerator Friday, November 12, 2010 9:45 AM Tuesday, November 09, 2010 1:36 AM Reply | Quote All replies 0 Sign in to vote Chrsitina Glabas wrote: Dim StrSQL As String StrSQL = "" StrSQL = "INSERT INTO tbl_records FacilityLocation VALUES 'Napa' " StrSQL = "INSERT INTO tbl_records( FacilityLocation) VALUES( 'Napa' ) " Mind the parentheses. Peter Doering [MVP Access] Marked as answer by VanderghastModerator Friday, November 12, 2010 9:45 AM Tuesday, November 09, 2010 1:36 AM Reply | Quote 0 Sign in to vote Peter is correct. One way to find out the correct syntax for any sql statement is to create the query itself, then switch from Design view to SQL view. But even better: once you have created the query, run it (e.g. using CurrentDB.Execute) rather than using in-line SQL.-Tom