Mark H
Lists at theopg.com
Tue Jul 1 14:06:22 CDT 2003
Not sure if this is any help, but I just tried it using ADO with the function, query and table in db1 and the code for getting the field names from an adodb.recordset in db2 (which also referenced db1). Worked fine... Mark -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of John Colby Sent: 01 July 2003 17:55 To: Access Developers discussion and problem solving Subject: RE: [AccessD] weird query def Yes, but were you running the code inside the database with the function? I am talking about a wizard where the code is external to the query db. It opens the database, sets a querydef and looks at the field collection. >From OUTSIDE the db that has the query and function it is not working here (in A2K). Function QryFldLst(strDBName As String, strQryName As String) As String On Error GoTo Err_QryFldLst Dim wks As DAO.Workspace Dim dbs As DAO.Database Dim fld As DAO.Field Dim str As String Dim qdf As DAO.QueryDef Set wks = DBEngine(0) Set dbs = wks.OpenDatabase(strDBName) Set qdf = dbs.QueryDefs(strQryName) For Each fld In qdf.Fields If Len(str) > 0 Then str = str & ";" End If str = str & fld.Name Next If Len(str) = 0 Then MsgBox strQryName & " NOT FOUND in " & "QryFldLst" Else QryFldLst = str End If Exit_QryFldLst: On Error Resume Next Set fld = Nothing If Not (dbs Is Nothing) Then dbs.Close: Set dbs = Nothing If Not (wks Is Nothing) Then wks.Close: Set wks = Nothing Exit Function Err_QryFldLst: Select Case Err Case 0 '.insert Errors you wish to ignore here Resume Next Case Else '.All other errors will trap Beep MsgBox Err.Description, , "Error in Function Module1.QryFldLst" Resume Exit_QryFldLst End Select Resume 0 '.FOR TROUBLESHOOTING End Function John W. Colby www.colbyconsulting.com -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com]On Behalf Of Mark H Sent: Tuesday, July 01, 2003 12:38 PM To: 'Access Developers discussion and problem solving' Subject: RE: [AccessD] weird query def John I just tried it using Access XP and a recordset and it worked. I created a query with a column called "X" which was the result of a function which multiplies table columns a and c. I then created an adodb.recordset, cycled through the fields and managed to debug.print each fields name. "X" was there... hth Mark -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://databaseadvisors.com/pipermail/accessd/attachments/20030701/33425068/attachment-0001.html>