473,387 Members | 1,532 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,387 software developers and data experts.

INSERT INTO statement in Access

31
Hello,

I have a table [QUESTOR Run tbl] and a duplicate table [QUESTOR Run tbl1] whose definition is smiliar to T but is empty without any values and also no primary key. my task is to

insert into QUESTOR Run tbl1 some values from QUESTOR Run tbl
I used the following Query:


INSERT INTO [QUESTOR Run tbl1][ID[, QUE$TOR Version Name[, Project ID[, Cost Tab[, Group[, Item[, Quantity[, Unit Rate[, Cost]]]]]]]]] SELECT [[QUESTOR Run tbl.]ID[, QUE$TOR Version Name[, Project ID[, Cost Tab[, Group[, Item[, Quantity[, Unit Rate[, Cost]]]]]]]] FROM [QUESTOR Run tbl] WHERE [QUESTOR Run tbl].[QUE$TOR Version Name]='7.3'

It comes up with an error in INSERT INTO statement.

What am i doing wrong here. I need help. Thank you.
Jul 23 '07 #1
7 2836
JKing
1,206 Expert 1GB
You've used square brackets wrongly in alot of places. Give this a try:
Expand|Select|Wrap|Line Numbers
  1. INSERT INTO [QUESTOR Run tbl1] ([ID], [QUE$TOR Version Name], [Project ID], [Cost Tab], [Group], [Item], [Quantity], [Unit Rate], [Cost])
  2. SELECT [ID], [QUE$TOR Version Name], [Project ID], [Cost Tab], [Group], [Item], [Quantity], [Unit Rate], [Cost]
  3. FROM [QUESTOR Run tbl] 
  4. WHERE [QUESTOR Run tbl].[QUE$TOR Version Name]='7.3'
  5.  
Jul 23 '07 #2
Flo100
31
You've used square brackets wrongly in alot of places. Give this a try:
Expand|Select|Wrap|Line Numbers
  1. INSERT INTO [QUESTOR Run tbl1] ([ID], [QUE$TOR Version Name], [Project ID], [Cost Tab], [Group], [Item], [Quantity], [Unit Rate], [Cost])
  2. SELECT [ID], [QUE$TOR Version Name], [Project ID], [Cost Tab], [Group], [Item], [Quantity], [Unit Rate], [Cost]
  3. FROM [QUESTOR Run tbl] 
  4. WHERE [QUESTOR Run tbl].[QUE$TOR Version Name]='7.3'
  5.  

Thank you very much. I used the same and now it gives me a Run time Error 3079: The specified field '[Project ID]' could refer to more than one table listed
in the FROM clause of your SQL statement. Where is the mistake? I am talking data from one table [QUESTOR Run Tbl] into [ QUESTOR Run tbl1].
Jul 23 '07 #3
JKing
1,206 Expert 1GB
Did you alter what I wrote at all?
I don't believe you need to specify tablenames for all fields in this case.

Make sure your FROM line only has the one table name.
Jul 23 '07 #4
ADezii
8,834 Expert 8TB
Thank you very much. I used the same and now it gives me a Run time Error 3079: The specified field '[Project ID]' could refer to more than one table listed
in the FROM clause of your SQL statement. Where is the mistake? I am talking data from one table [QUESTOR Run Tbl] into [ QUESTOR Run tbl1].
Preface the Fields in the SELECT Clause with the proper Table Identifier and you should be OK:
Expand|Select|Wrap|Line Numbers
  1. INSERT INTO [QUE$TOR Run tbl1] ( ID, [QUE$TOR Version Name], [Project ID], [Cost Tab], [Group], Item, Quantity, [Unit Rate], Cost )
  2. SELECT [QUESTOR Run tbl].ID, [QUESTOR Run tbl].[QUE$TOR Version Name], [QUESTOR Run tbl].[Project ID], 
  3. [QUESTOR Run tbl].[Cost Tab], [QUESTOR Run tbl].Group, [QUESTOR Run tbl].Item, [QUESTOR Run tbl].Quantity, 
  4. [QUESTOR Run tbl].[Unit Rate], [QUESTOR Run tbl].Cost
  5. FROM [QUESTOR Run tbl]
  6. WHERE ((([QUESTOR Run tbl].[QUE$TOR Version Name])="7.3"));
Jul 23 '07 #5
Flo100
31
Did you alter what I wrote at all?
I don't believe you need to specify tablenames for all fields in this case.

Make sure your FROM line only has the one table name.

Yes I did, Infact I tried icluding the full name for each field like :

INSERT INTO [QUESTOR Run tbl1] ([ID], [QUE$TOR Version Name], [Project ID], [Cost Tab], [GROUP], [Item], [Quantity], [Unit Rate], [Cost])
SELECT [QUESTOR Run tbl].[ID], [QUESTOR Run tbl].[QUE$TOR Version Name], [QUESTOR Run tbl].[Project ID], [QUESTOR Run tbl].[Cost Tab], [QUESTOR Run tbl].[GROUP], [QUESTOR Run tbl].[Item], [QUESTOR Run tbl].[Quantity], [QUESTOR Run tbl].[Unit Rate], [QUESTOR Run tbl].[Cost]
FROM [QUESTOR Run tbl]
WHERE [QUESTOR Run tbl].[QUE$TOR Version Name]='7.3'
Jul 23 '07 #6
Flo100
31
Preface the Fields in the SELECT Clause with the proper Table Identifier and you should be OK:
Expand|Select|Wrap|Line Numbers
  1. INSERT INTO [QUE$TOR Run tbl1] ( ID, [QUE$TOR Version Name], [Project ID], [Cost Tab], [Group], Item, Quantity, [Unit Rate], Cost )
  2. SELECT [QUESTOR Run tbl].ID, [QUESTOR Run tbl].[QUE$TOR Version Name], [QUESTOR Run tbl].[Project ID], 
  3. [QUESTOR Run tbl].[Cost Tab], [QUESTOR Run tbl].Group, [QUESTOR Run tbl].Item, [QUESTOR Run tbl].Quantity, 
  4. [QUESTOR Run tbl].[Unit Rate], [QUESTOR Run tbl].Cost
  5. FROM [QUESTOR Run tbl]
  6. WHERE ((([QUESTOR Run tbl].[QUE$TOR Version Name])="7.3"));

I just tried like what you described above. it still gives me the same error.
Jul 23 '07 #7
Flo100
31
I just tried like what you described above. it still gives me the same error.
I got it. My first mistake was in the [QUESTOR Run tbl] the field [Project ID] did not have a space meaning it was [ProjectID] and there was a single quote missing after 7.3

My mistakes were silly. sorry about that. And thank you very much for helping.
Jul 23 '07 #8

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

Similar topics

6
by: Karen Middleton | last post by:
In MS Access I can do in one SQL statement a update if exists else a insert. Assuming my source staging table is called - SOURCE and my target table is called - DEST and both of them have the...
16
by: robert | last post by:
been ruminating on the question (mostly in a 390/v7 context) of whether, and if so when, a row update becomes an insert/delete. i assume that there is a threshold on the number of columns of the...
1
by: 2BaCook | last post by:
Hi, I have an Access database that I am creating a java front end to. I am trying to insert a record into a table and get a problem whenever I try to insert into my "Number" column. Here is my...
2
by: terpatwork | last post by:
Hi, (1) I have an access form that allows users to enter data, and when they click a button, the OnClick code that I've written uses a SQL INSERT statement to insert the data into the database. I...
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...
2
by: Geoffrey KRETZ | last post by:
Hello, I'm wondering if the following behaviour is the correct one for PostGreSQL (7.4 on UNIX). I've a table temp_tab with 5 fields (f1,f2,f3,...),and I'm a launching the following request :...
7
by: Cindy H | last post by:
Hi I'm having a problem getting the insert statement correct for an Access table I'm using. The Access table uses an autonumber for the primary key. I have tried this: INSERT INTO Tournaments...
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...
3
by: Dave | last post by:
I have an old web app that ues an Access database and ASP 3.0. I need to build an INSERT statement based on the contents of a form. What is the best way to handle blank text boxes that are...
3
by: Greg Corradini | last post by:
Hello, I'm trying to perform a simple insert statement into a table called Parcel_Test (see code below). Yet, I get an error message that I've never seen before (see traceback below). I've tried...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.