John Colby
jcolby at colbyconsulting.com
Tue Jul 1 11:55:19 CDT 2003
MessageYes, 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/6b6fe161/attachment-0001.html>