3264 "no field defined--cannot append tabledef" on create temp table from query (1 Viewer)

Vbark

Registered User.
Local time
Tomorrow, 08:35
Joined
Jan 23, 2007
Messages
29
Error getting field names from query

Hi I have the following function designed to make a temp table out of a select query, it works for all queries except on one I get the error message:

3264 "no field defined--cannot append tabledef"

The reason for this is when it gets to the "For Each fld In qdf.Fields" part it cannot see any fields in the query so doesn't appned any.

I have tried
* compact and repair
* decompile
* recreating the query
* jetcomp
* for i = 0 to qdf.Fields.Count - 1


Any ideas,


The function…...
Public Sub CreateTempTableQuery(QueryName As String, TempTableName As String)
Dim tdf As DAO.TableDef
Dim qdf As DAO.QueryDef
Dim fld As DAO.Field



Set tdf = DBEngine(0)(0).CreateTableDef(TempTableName)
Set qdf = DBEngine(0)(0).QueryDefs(QueryName)


For Each fld In qdf.Fields
tdf.Fields.Append tdf.CreateField(fld.Name, fld.Type)
Next fld

DBEngine(0)(0).TableDefs.Append tdf


End Sub
 
Last edited:

Dennisk

AWF VIP
Local time
Today, 21:35
Joined
Jul 22, 2004
Messages
1,649
why not turn your select query into a make table query?
 

Vbark

Registered User.
Local time
Tomorrow, 08:35
Joined
Jan 23, 2007
Messages
29
Initially I did but if there is more than one autonumber field in the query it fails.

none the less I did persevere and ended up doing

if qdf.fields.count = 0 then
turn it into a recordset and get the fields from that and that worked for some strange reason
 

Users who are viewing this thread

Top Bottom