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 to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Access > End of statement error in INSERT INTO statement

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-20-02, 16:06
alicejwz alicejwz is offline
Registered User
 
Join Date: May 2002
Posts: 395
End of statement error in INSERT INTO statement

I have this SQL statement:

INSERT INTO tblAnalysis
SELECT * FROM table2;

It generated the following error message and is highlighting "tblAnalysis
Compile error:
Expected: End of statement

Why??
Reply With Quote
  #2 (permalink)  
Old 12-20-02, 19:13
tcmug tcmug is offline
Registered User
 
Join Date: Sep 2002
Location: MA
Posts: 24
I think you may have tried to drag the entire table (to be inserted) into the append row. Try specifying the field to be appended to (ie: SELECT tblName.chrFieldName).

Tim
Reply With Quote
  #3 (permalink)  
Old 12-23-02, 15:43
alicejwz alicejwz is offline
Registered User
 
Join Date: May 2002
Posts: 395
INSERT Statement

Quote:
Originally posted by tcmug
I think you may have tried to drag the entire table (to be inserted) into the append row. Try specifying the field to be appended to (ie: SELECT tblName.chrFieldName).

Tim
Hi Tim,
What I want to do is INSERT the value of each field FROM Table2 INTO tblRGAAnalysis. Must I specify all the fields in the FROM table?

Thanks!!
Reply With Quote
  #4 (permalink)  
Old 12-23-02, 15:43
alicejwz alicejwz is offline
Registered User
 
Join Date: May 2002
Posts: 395
INSERT Statement

Quote:
Originally posted by tcmug
I think you may have tried to drag the entire table (to be inserted) into the append row. Try specifying the field to be appended to (ie: SELECT tblName.chrFieldName).

Tim
Hi Tim,
What I want to do is INSERT the value of each field FROM Table2 INTO tblRGAAnalysis. Must I specify all the fields in the FROM table?

Thanks!!
Reply With Quote
  #5 (permalink)  
Old 12-23-02, 15:47
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 20,000
must you specify all the fields in the FROM table? no, but if you don't, there has to be an exact match in the number of columns and their datatypes

in particular, if the receiving table has an autonumber, you will need to list the fields, because the autonumber column cannot have values fed into it, so it has to be excluded from the list of fields

rudy
http://rudy.ca/
Reply With Quote
  #6 (permalink)  
Old 12-23-02, 15:54
alicejwz alicejwz is offline
Registered User
 
Join Date: May 2002
Posts: 395
Re: INSERT Statement

Quote:
Originally posted by alicejwz
Hi Tim,
What I want to do is INSERT the value of each field FROM Table2 INTO tblRGAAnalysis. Must I specify all the fields in the FROM table?

Thanks!!
What I forgot to mention is that I have 21 fields(values) in Table2 which I like to insert into tblAnayses that I created in SQL statement. I really prefer not to list all the fields in the table. Could you help?

Thanks!
Reply With Quote
  #7 (permalink)  
Old 12-23-02, 16:21
alicejwz alicejwz is offline
Registered User
 
Join Date: May 2002
Posts: 395
Quote:
Originally posted by r937
must you specify all the fields in the FROM table? no, but if you don't, there has to be an exact match in the number of columns and their datatypes

in particular, if the receiving table has an autonumber, you will need to list the fields, because the autonumber column cannot have values fed into it, so it has to be excluded from the list of fields

rudy
http://rudy.ca/
Hello Rudy,
I have an array of 20 elements which I like to store it in a table.
The array function stored the values into each element(cell) of the array,
I created the table definition in which the values of array is to be stored in SQL statement. They are working fine.

But in the INSERT statement is not working. It is giving me a syntax error on "INSERT INTO tblRGAAnalysis" in the SQL statement.
I verified the Table2(FROM Table) table definition and values they matched up to TO table.



'table definition for receiving table
Public Sub cmdCreateTbl_Click()
Dim StrSQL As String

StrSQL = "Create Table tblRGAAnalysis "
StrSQL = StrSQL & "(Quarter TEXT, 0 NUMBER, 1 NUMBER, 2 NUMBER, 3 NUMBER, "
StrSQL = StrSQL & "4 NUMBER, 5 NUMBER, 6 NUMBER, 7 NUMBER, 8 NUMBER, "
StrSQL = StrSQL & "9 NUMBER, 10 NUMBER, 11 NUMBER, 12 NUMBER, 13 NUMBER, "
StrSQL = StrSQL & "14 NUMBER, 15 NUMBER, 16 NUMBER, 17 NUMBER, 18 NUMBER, "
StrSQL = StrSQL & "19 NUMBER, totRGA NUMBER);"

Set db = CurrentDb
db.Execute StrSQL
RefreshDatabaseWindow

INSERT INTO tblRGAAnalysis
SELECT * FROM Table2;

End sub

Could you help?

Thanks!!
Reply With Quote
  #8 (permalink)  
Old 12-23-02, 19:00
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 20,000
i don't know that "sub" language (vb? asp?), only sql

but i bet it's your numeric column names

after all this time, i bet you could have typed the select list columns

try putting them in square brackets


rudy
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On