Hello:
the below code would cycle through all the fields in a table or query and display the title of the column in a message box:
On Error GoTo Procedure_Error
Dim db As Database
Dim rs As DAO.Recordset
Dim fld As Field
Dim strRowSource As String
'
Set db = CurrentDb()
Set rs = db.OpenRecordset("tblAscii")
'
MsgBox "Date this recordset created: " & rs.DateCreated
MsgBox "Number of field(s) in this recordset = " & rs.Fields.Count
For Each fld In rs.Fields
MsgBox fld.Name
'Do some more work here
Next fld
'
rs.Close
CurrentDb.Close
***********************
To cycle through the list of available queries in a database you could use the ALLQueries Collection such as:
Sub AllQueries()
Dim obj As AccessObject, dbs As Object
Set dbs = Application.CurrentData
' Search for open AccessObject objects in AllQueries collection.
For Each obj In dbs.AllQueries
If obj.IsLoaded = True Then
' Print name of obj.
Debug.Print obj.Name
End If
Next obj
End Sub
'
Regards
Mark