473,421 Members | 1,556 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,421 software developers and data experts.

INSERT INTO statement, what is wrong with my syntax? :(

Hi,
I have to insert 10 pieces of data (8 from text or combo boxes, and 2 from variables), into my table. I'm sure Im getting the quotes wrong somewhere, but whatever I try I just cant see anything wrong.
I'd really appreciate it If someone could help me with this, Its driving me crazy!
The Code is below:
Expand|Select|Wrap|Line Numbers
  1. DoCmd.RunSQL "INSERT INTO tblDocs ([Doc Name],[Doc Code],[Description],[DepC],[Version],[Master],[Authorised],[Physical Location],[Publish Date],[Current]) Values (" '" & Me.combo18 & "','" & Me.[Doc Code] & "','" & Me.Description & "','" & Me.combo16 & "','" & Me.text20 & "','" & Newlink & "','" & Me.NewLinkPdf & "','" & Me.hardcopy& "','" & Me.[Publish Date] & "','" & "Yes");"
  2.  
Many thanks
Sam
Aug 22 '07 #1
5 1501
istya
35
Hi,
I have to insert 10 pieces of data (8 from text or combo boxes, and 2 from variables), into my table. I'm sure Im getting the quotes wrong somewhere, but whatever I try I just cant see anything wrong.
I'd really appreciate it If someone could help me with this, Its driving me crazy!
The Code is below:

DoCmd.RunSQL "INSERT INTO tblDocs ([Doc Name],[Doc Code],[Description],[DepC],[Version],[Master],[Authorised],[Physical Location],[Publish Date],[Current]) Values (" '" & Me.combo18 & "','" & Me.[Doc Code] & "','" & Me.Description & "','" & Me.combo16 & "','" & Me.text20 & "','" & Newlink & "','" & Me.NewLinkPdf & "','" & Me.hardcopy& "','" & Me.[Publish Date] & "','" & "Yes");"

Many thanks
Sam
You only need the quotes in the SQL statement aroung the text values, the others don't require quotes. Are all your fields text? Have you tried viewing the completed string before you run the SQL?
Aug 22 '07 #2
Does text values include the commas between the items?
Aug 22 '07 #3
istya
35
Does text values include the commas between the items?
I mean are Me.combo18, Me.[Doc Code], Me.Description, Me.combo16, Me.text20, Newlink, Me.NewLinkPdf, Me.hardcopy and Me.[Publish Date] text values or are some numbers? Also I notice that you have a date - is that in a date format or not? The datatype that needs quotes in a SQL statement is text, as far as I am aware, number and dates don't need the quotes.

Does that explain what I mean better?
Aug 22 '07 #4
JKing
1,206 Expert 1GB
Assuming they are all text fields. Try this:

Expand|Select|Wrap|Line Numbers
  1. DoCmd.RunSQL "INSERT INTO tblDocs ([Doc Name],[Doc Code],[Description],[DepC],[Version],[Master],[Authorised],[Physical Location],[Publish Date],[Current]) Values ('" & Me.combo18 & "','" & Me.[Doc Code] & "','" & Me.Description & "','" & Me.combo16 & "','" & Me.text20 & "','" & Newlink & "','" & Me.NewLinkPdf & "','" & Me.hardcopy & "','" & Me.[Publish Date] & "', Yes);"
  2.  
Aug 22 '07 #5
Huge thanks, that works perfectly!

To itsya - you were clear, i just didnt know if the commas were quoted.

Thanks very much!
Aug 22 '07 #6

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

Similar topics

4
by: Simom Thorpe | last post by:
Hi, I'm trying to insert a line into a MS access DB using ASP on IIS 5. This is the line: con.execute "INSERT INTO newProds(title,desc,catcode) VALUES ('Champagne Muff Scarf','','AC304B')"...
6
by: Gérard Leclercq | last post by:
ACCESS First fields are TEXT, last 2 are Numbers The name of the fields are correct. Dim MyConn Set MyConn=Server.CreateObject("ADODB.Connection") MyConn.Open...
12
by: Bob Stearns | last post by:
This is probably the wrong forum for this, but I thought it might start some discussion. The INSERT statement, in its current form, has problems being formatted so a human reader can follow it....
7
by: kosta | last post by:
hello! one of my forms communicates with a database, and is supposed to add a row to a table using an Insert statement... however, I get a 'oledb - syntax error' exception... I have double...
3
by: Nathan Sokalski | last post by:
When trying to submit data to an Access database using ASP.NET I recieve the following error: System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(Int32 hr) +41...
1
by: Joe | last post by:
Hello All, I am trying to insert a record in the MS Access DB and for some reason I cannot get rid of error message, System.Data.OleDb.OleDbException: Syntax error in INSERT INTO statement. ...
3
by: brianbasquille | last post by:
Hello all, Strange little problem here... am just trying to insert some basic information into an Access Database using OleDB. I'm getting a "Syntax error in Insert Into statement" when it...
15
by: abracad_1999 | last post by:
I am trying to populate a table with the following insert query run through phpmyadmin. When I attempt to run it phpmyadmin just freezes. After a while "Fatal error: Maximum execution time of 300...
6
by: rn5a | last post by:
During registration, users are supposed to enter the following details: First Name, Last Name, EMail, UserName, Password, Confirm Password, Address, City, State, Country, Zip & Phone Number. I am...
1
by: teddymeu | last post by:
Hi Guys, trying to bulk insert a csv file into my SQL database from an asp.net vb web app/form page that the user uploads, my problem is that im new to all this and although the SQL statement...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...

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.