ErrorHandler:
MsgBox “Error No: “ & err.Number _
& “; Description: “ & err.Description
Resume ErrorHandlerExitEnd SubPublic Sub ListQueryFields(ByVal control As IRibbonControl)On Error Resume NextDim strQueryName As String
Dim qdf As DAO.QueryDefFirst, clear data from the old table of query and field names:strTable = “zstblQueryAndFieldNames”
strReport = “zsrptQueryAndFieldNames”
DoCmd.SetWarnings False
strSQL = “DELETE * FROM “ & strTable
DoCmd.RunSQL strSQLFill the table with query and field names, iterating through the database’s QueryDefs collection
(only select queries will have their fields listed):Set dbs = CurrentDb
Set rst = dbs.OpenRecordset(strTable, dbOpenTable)For Each qdf In dbs.QueryDefs
strQueryName = qdf.Name
Debug.Print “Query name: “ & strQueryName
If Left(strQueryName, 4) <> “MSys” Then
Set flds = qdf.Fields
For Each fld In flds
strFieldName = fld.Name
With rst
.AddNew
!QueryName = strQueryName
!FieldName = strFieldName
!DataType = fld.Type
!Required = fld.Required
.Update
End With
Next fld
End If
Next qdfrst.CloseDoCmd.OpenTable strTablePart III Adding More Functionality to Office