Access VBADiscuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Access VBA section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.
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