abenitez77
IS-IT--Management
I get an error on the last line that says "Syntax error (missing operator) in query expression 'O.Object_ID = C.Object_ID INNER JOIN sys.types As T ON C.System_Type_ID = T.System_Type_I' ". I am using ms access 2007 and It runs fine when I run it in sql studio.
Dim db As DAO.Database
Dim qODBC As DAO.QueryDef
Dim sqODBC As String, sConnectDAO As String
Set db = CurrentDb
Set Conn = Application.CurrentProject.Connection
sqODBC = "qry_PassThru_" & strSQLTableName & "_REF"
sql = "SELECT O.name as TableName, C.Name as ColumnName, C.Max_Length as ColumnSize, T.Name as ColumnType, C.precision, C.scale "
sql = sql & "FROM sys.objects AS O "
sql = sql & "INNER JOIN sys.columns AS C ON O.Object_ID = C.Object_ID "
sql = sql & "INNER JOIN sys.types As T ON C.System_Type_ID = T.System_Type_ID "
sql = sql & "WHERE O.type = 'U' AND T.schema_id = '4' AND O.name = '" & strSQLTableName & "' "
sql = sql & "ORDER BY 1, 2, 3, 4"
'MsgBox sql
Set qODBC = db.CreateQueryDef(sqODBC, sql)
Dim db As DAO.Database
Dim qODBC As DAO.QueryDef
Dim sqODBC As String, sConnectDAO As String
Set db = CurrentDb
Set Conn = Application.CurrentProject.Connection
sqODBC = "qry_PassThru_" & strSQLTableName & "_REF"
sql = "SELECT O.name as TableName, C.Name as ColumnName, C.Max_Length as ColumnSize, T.Name as ColumnType, C.precision, C.scale "
sql = sql & "FROM sys.objects AS O "
sql = sql & "INNER JOIN sys.columns AS C ON O.Object_ID = C.Object_ID "
sql = sql & "INNER JOIN sys.types As T ON C.System_Type_ID = T.System_Type_ID "
sql = sql & "WHERE O.type = 'U' AND T.schema_id = '4' AND O.name = '" & strSQLTableName & "' "
sql = sql & "ORDER BY 1, 2, 3, 4"
'MsgBox sql
Set qODBC = db.CreateQueryDef(sqODBC, sql)