|
Subject:
|
Error getting field names from query
|
|
Posted By:
|
vbark
|
Post Date:
|
1/22/2007 8:42:03 PM
|
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
|
|
Reply By:
|
vbark
|
Reply Date:
|
1/23/2007 8:04:36 PM
|
I got there in the end by doing a work around along the lines of
if qdf.fields.count = 0 then
turn it into a recordset and get the fields from that which worked for some strange reason
|