Access MVP (2010-2015)


Sort by Descriptions is gone in Access 2007 and up but…

…you can see them, thanks to a post by JoelS_999 in the Microsoft Community Forums.  And, while this may not be exactly what you want, this neat little piece of code will allow you to see them in a table, tblSysObjProps.  This is especially helpful when upgrading from Access 2003 and below, where you have used Descriptions to store information pertinent to your Object.

Public Function ListObjProps()
' Created by Joel S. on 12/05/2013
' This function lists MS Access 2010 objects (i.e. tables, queries, forms, reports,
' etc.) and their top-level properties as shown in the navigation pane. The output
' is written into a table, which allows an open, grid-like view of the object
' properties, similar to the navigation pane in Access 2000-2003.  Also, the output
' table makes it possible to sort on the Description field, which the Access 2010
' navigation pane does not allow.
' CAVEATS: The DateCreated and LastUpdated fields will reflect the values stored
' in the MSysObjects system table, not the values shown in the navigation pane
' (which sometimes appear to be incorrect).  Also, the Type field will show "Tables" not
' "Queries" for query objects, so this could cause confusion if some of the tables
' and queries in the database use exactly the same names.  Finally, this function should
' be run whenever the user deems he/she has added/deleted/modified enough
' MS Access objects to warrant refreshing the output table.

On Error GoTo Err_ListObjProps

Dim db As Database 'Variable for current database
Dim ctnr As Container 'High-level containers for MS Access objects
Dim obj As Document 'Individual MS Access Objects--tables, queries, forms, etc.
Dim prop As DAO.Property 'Object properties
Dim tdf As TableDef 'Output table definition
Dim strTbl As String 'Output table name
Dim rst As Recordset 'Recordset for updating output table
Dim boolRstOpen As Boolean 'Flag to indicate whether recordset is open

'Turn off warnings
DoCmd.SetWarnings False
DoCmd.Hourglass True

boolRstOpen = False 'Initiate flag to indicate recordset hasn't been opened.
Set db = CurrentDb()
strTbl = "tblSysObjProps" 'Name output table. (Can be renamed if user wishes.)

On Error Resume Next
'Close and delete previous output table if needed
DoCmd.Close acTable, strTbl, acSaveNo
DoCmd.DeleteObject acTable, strTbl
On Error GoTo Err_ListObjProps

'Create new output table definition
Set tdf = db.CreateTableDef(strTbl)
With tdf
  .Fields.Append .CreateField("Name", dbText)
  .Fields.Append .CreateField("Type", dbText)
  .Fields.Append .CreateField("Description", dbText)
  .Fields.Append .CreateField("DateCreated", dbDate)
  .Fields.Append .CreateField("LastUpdated", dbDate)
End With
'Append new output table definition to database
db.TableDefs.Append tdf

'Open output table for updating
Set rst = db.OpenRecordset(tdf.Name)
boolRstOpen = True
If (rst.RecordCount > 0) Then
End If

'Cycle through all container types--tables, queries, forms, reports, etc.
For Each ctnr In db.Containers
  'Cycle through each object in the container--individual tables, queries, etc.
  For Each obj In ctnr.Documents
    'Create new record in output table
      'Print object name to immediate window if needed
      'Debug.Print obj.Name
      'Cycle through each top-level property for the object in question
      'and write the value for each specified property into output table.
      For Each prop In obj.Properties
        Select Case prop.Name
          Case "Container"
            rst!Type = prop.Value
          Case "DateCreated"
            rst!DateCreated = prop.Value
          Case "Description"
            rst!Description = prop.Value
          Case "LastUpdated"
            rst!LastUpdated = prop.Value
          Case "Name"
            rst!Name = prop.Value
        End Select
        'Print object properties to immediate window if needed
        'Debug.Print vbTab & prop.Name & " = " & prop.Value
      Next prop
      'Update output table for last record entered.
  Next obj
Next ctnr

'Clean up and close function
If boolRstOpen Then
End If
'MS Access quirk requires the hidden output table to be explicitly hidden then unhidden.
Application.SetHiddenAttribute acTable, strTbl, True
Application.SetHiddenAttribute acTable, strTbl, False
DoCmd.Hourglass False
DoCmd.SetWarnings True
MsgBox ("ListObjProps function completed successfully. See table " _
  & strTbl & " for output.")
Exit Function

  'Clean up and close function
  On Error Resume Next
  If boolRstOpen Then
  End If
  DoCmd.Hourglass False
  DoCmd.SetWarnings True
  MsgBox ("ERROR: ListObjProps function did not complete successfully.")
End Function

Still missing the Database Window?  Here are some options…
AAD Consulting’s Database Window for Access 2007 and Access 2010
Avenius Gunter’s Database Window for Access 2007, Access 2010 and Access 2013
Access Junkie’s Database Window for Access 2007

267 total views, 1 views today

2 comments to Sort by Descriptions is gone in Access 2007 and up but…

  • danno,

    To open a Form in Design View you just need to use this line…

    DoCmd.OpenForm “YourFormName”, acDesign

    Now, I do not use Datasheet View but I would think you could get that to work by using something like…

    ‘Untested Air Code
    Dim strMyForm As String
    strMyForm = Me.txtYourFieldThatContainsFormName

    DoCmd.OpenForm strMyForm, acDesign

    … in the On_Click event of the Control. And, don’t forget to set the *Display as Hyperlink* to *Always*!

  • danno

    This is outstanding. I was finally forced to move to 2010 from 2003 and to say I’ve been greatly hobbled by the lack of sorting on Descriptions is an understatement. My main db has 1157 objects. This type of sorting is vital for me.

    I created a datasheet form to sort all of the objects. Crazy question: is it possible to create a hyperlink of sorts with the Name field to open that object in design view? I’d just about be back to a real development environment if that’s possible.