Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Syntax Error in From Clause - Insert Into 1

Status
Not open for further replies.

jjlogan

Programmer
Jan 11, 2002
178
US
This is mean. I have code behind a form that runs action queries (make-table, append, ...) to automate about 30 steps. One section of code includes an ADO recordset open statement that executes an Insert Into SQL query:
Here's a snipet (after dim'ing etc.):
Set con = New ADODB.Connection
con.Open CurrentProject.Connection
Set rs1 = New ADODB.Recordset
strQuery = "INSERT INTO CumCosts SELECT * FROM UpdatedBCIV-IROverheadAmt;"
rs1.Open strQuery, con, , , adCmdText

I get error "Syntax Error in From Clause". I have checked that the two tables have identical fields (number of fields, names and data types of fields all same).
Other steps I've done to troubleshoot:
1) Just before executing this rs1.Open line of code, I leave the VBA and check the above table named "Updated..." and there is one (1) record in it just waiting to be appended - seems ready.
2) I even commented out all the above code related to programmically appending, and then when get to this point in the code, I leave VBA and run the identifcal append query created from Query Design grid and it works fine. Then I come back to VBA section and proceed to end of sub.
3) I have a section of code in same subroutine that does exactly the same Insert Into (into the same table, but from a different table, but again with all the same fields).

Any help or suggestions greatly appreciated.
Jeff
 
If you must use subtraction signs in object names, you need to wrap the names in []s.
Code:
strQuery = "INSERT INTO CumCosts SELECT * FROM [UpdatedBCIV-IROverheadAmt];"


Duane
Hook'D on Access
MS Access MVP
 
Thanks Duane,
Yep, that solved it. I put [] around the FROM table and let the INTO table alone w/o the [] and it worked.
Thanks much! This saved us big time as we have a deadline today. Jeff
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top