Click to See Complete Forum and Search --> : SQL syntax
demmith
April 5th, 2001, 08:48 AM
I am getting a syntax error in the FROM clause error and for the life of me I cannot see what is wrong with my SQL string. Here it is:
SQLStmt = "SELECT " & strTableName & ".* INTO [CLEARANCE] FROM " & strTableName
strTableName is the name of a table that I extracted from TableDef earlier in the module. Am I blind? :-)
Iouri
April 5th, 2001, 09:06 AM
Try this
SQLStmt = "SELECT * INTO NewTable FROM " & strTableName
or if you need to insert into different table
SQLStmt = "INSERT INTO NewTable SELECT * FROM " & strTableName
Iouri Boutchkine
iouri@hotsheet.com
demmith
April 5th, 2001, 09:37 AM
No, not quite what I was looking for. I just happened to stumble upon the solution just a couple minutes ago. I had forgotten to mention that the table name represented by strTableName has two forward slashes in it. I thought there was no problem with that because in an earlier procedure I was using the reverse process and putting the table name (that contains slashes) in an INTO clause and VB did not complain one bit, but for some quirky reason it does complain when those same table names are in the FROM clause. So what I had to do is surround my table name variable with backquotes (NOT single quotes, but the quote found on the tilde (˜) key) like this:
SQLStmt = "SELECT " & strTableName & ".* INTO [CLEARANCE] FROM `" & strTableName & "`"
dbClearance.Execute (SQLStmt)
aagregoire
April 5th, 2001, 03:17 PM
this sounds like an "INSERT" statment
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.