p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > Microsoft Office > Access and Access VBA > Access VBA
I forgot my password Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Access VBA Discuss 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.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 22nd, 2007, 09:42 PM
Registered User
 
Join Date: Jun 2006
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old January 23rd, 2007, 09:04 PM
Registered User
 
Join Date: Jun 2006
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
XSLT For Each - Field Names lahatfield XSLT 6 May 15th, 2007 07:33 AM
Query statement has nonexistent field names-FIXED buddyz Classic ASP Databases 3 August 30th, 2006 10:46 AM
Get Field Names fizzerchris Classic ASP Databases 1 February 25th, 2006 05:06 AM
Retrieving Field Names RayRedSox Classic ASP Basics 0 October 12th, 2005 03:16 PM
Retrieving Dynamic Field Names tdaustin Classic ASP Basics 4 January 12th, 2004 11:10 AM



All times are GMT -4. The time now is 06:49 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc