the code I am working on imports a txt file into a temporary table - the table names and fields change with each txt file that is imported - so I do not know what the field names will be or tables being used to import the data
here is what I currently have for code
Dim db As Database
Dim rs As Recordset
Dim rsDATA As Recordset, rsID As Recordset
Dim tb As TableDef
Dim intRS As Integer, FldNo As Integer
Dim x As Long, lngID As Long
Dim strTName As String, strfield As String, strTMP As String, strQuery As String
Dim fld As Field
Set db = CurrentDb
Set rs = db.OpenRecordset("SELECT DISTINCT tblTableDetail.[tTables],tblTableDetail.[Import_Priority] FROM tblTableDetail WHERE (tblTableDetail.[EDI_Transaction]= '" & strTrans & "') ORDER BY Import_Priority;")
'loop through Table Detail to get each table need for 'insert statement
Do Until intRS = rs.RecordCount
strTName = rs!tTables 'destination table
strTMP = "TMP" & strTName
Set rsDATA = db.OpenRecordset(strTMP) 'Temporary table holding the data
Set tb = db.TableDefs(strTName)
Set rsID = db.OpenRecordset(strTName)
' Load the recordset's data into new table
' an INSERT statement for each.
'Here is where the code stops
'I know the statement is not correct
'but not sure if this statement is possible
'I just want to insert all from one table into another
strQuery = ("INSERT INTO strTName SELECT * FROM strTMP;")
con.Execute strQuery ' add the record
'the error message is - 424-Object required
here is what I currently have for code
Dim db As Database
Dim rs As Recordset
Dim rsDATA As Recordset, rsID As Recordset
Dim tb As TableDef
Dim intRS As Integer, FldNo As Integer
Dim x As Long, lngID As Long
Dim strTName As String, strfield As String, strTMP As String, strQuery As String
Dim fld As Field
Set db = CurrentDb
Set rs = db.OpenRecordset("SELECT DISTINCT tblTableDetail.[tTables],tblTableDetail.[Import_Priority] FROM tblTableDetail WHERE (tblTableDetail.[EDI_Transaction]= '" & strTrans & "') ORDER BY Import_Priority;")
'loop through Table Detail to get each table need for 'insert statement
Do Until intRS = rs.RecordCount
strTName = rs!tTables 'destination table
strTMP = "TMP" & strTName
Set rsDATA = db.OpenRecordset(strTMP) 'Temporary table holding the data
Set tb = db.TableDefs(strTName)
Set rsID = db.OpenRecordset(strTName)
' Load the recordset's data into new table
' an INSERT statement for each.
'Here is where the code stops
'I know the statement is not correct
'but not sure if this statement is possible
'I just want to insert all from one table into another
strQuery = ("INSERT INTO strTName SELECT * FROM strTMP;")
con.Execute strQuery ' add the record
'the error message is - 424-Object required