SQL Syntax error in CREATE TABLE statement in MS Access VBA subroutine -


i working on subroutine in microsoft access vba. intended purpose of program create new table called newtablename , perform join on 2 tables tablename1 , tablename2. result of join should stored in newtablename. research online, led believe cannot create empty table store joined data in. so, have attempted duplicate tablenname2 , store data in newtablename until join performed.

however, following error when run program:

run-time error '-2147217900 (80040e14)':

syntax error in create table statement.

from line:

currentproject.connection.execute strnewtablequery 

which tested user input resulting in query:

create table [unix_lob] select * unix 

here code:

option compare database  public sub joinwithiimmmodule()      dim sqlnewtablequery    string     dim sqljoinquery        string     dim tablename1          string     dim tablename2          string     dim newtablename        string     dim commonfield         string      ' set common field used join 2 tables '     commonfield = "[code]"      ' set tablename1 used in join. '     tablename1 = "iimm"      ' acquire name of table joined table1 user'     tablename2 = inputbox("enter name of table join " + tablename1 + ":", _              "table split", "unix")      ' set name of new table joins stored.'     newtablename = "[" + tablename2 + "_lob]"      ' create newtablename, duplicate of tablename2 table.'     ' joined data reside.'     sqlnewtablequery = "create table " + newtablename + " select * " + tablename2     debug.print sqlnewtablequery     currentproject.connection.execute sqlnewtablequery      ' join tablename1 , tablename2 on commonfield, , store joined data in newtablename'     sqljoinquery = "select " + tablename1 + ".*, " + tablename2 + ".*" & _                  "into " + newtablename & _                  "from " + tablename1 & _                  "inner join " + tablename2 & _                  "on " + tablename1 + "." + commonfield + " = " + tablename2 + "." + commonfield + ";"     debug.print sqljoinquery     currentdb.execute sqljoinquery  end sub 

does know might causing error?


Comments