This will get you started
Function GetDescription(ObjName As String, ObjType As Long) As String
' Get descriptions of Forms, Reports. Queries etc
On Error GoTo GetDescriptions_Err
Select Case ObjType
Case -32768 ' Forms
GetDescription cription =
CurrentDb.Containers!Forms.Documents(ObjName).Properties("Description")
Case -32766 ' Macro Scripts
GetDescription cription =
CurrentDb.Containers!Scripts.Documents(ObjName).Properties("Description")
Case -32764 ' Reports
GetDescription cription =
CurrentDb.Containers!Reports.Documents(ObjName).Properties("Description")
Case -32761 ' Modules
GetDescription cription =
CurrentDb.Containers!Modules.Documents(ObjName).Properties("Description")
'Case -32758 ' Admin
'case -32752 ' Access Info
Case 1 ' tables
GetDescription cription =
CurrentDb.TableDefs(ObjName).Properties("Description") ' Or ("DateCreated")
etc
Case 2 ' Databases
GetDescription cription =
CurrentDb.Containers!Databases.Documents(ObjName).Properties("Description")
Case 3 ' Objects
GetDescription cription =
CurrentDb.Containers!Objects.Documents(ObjName).Properties("Description")
Case 5 ' Queries
GetDescription cription =
CurrentDb.QueryDefs(ObjName).Properties("Description")
Case 6 ' Attached tables
GetDescription cription = "Attached " &
CurrentDb.Containers!TableDefs.Documents(ObjName).Properties("Description")
'Case 9 ' SQL
Case Else
GetDescription = "Unavailable Information"
End Select
Exit Function
GetDescriptions_Err:
If If Err = 3270 Or Err = 3265 Then ' Property doesn't exist
Resume Next
Else
MsgBox Err.Description
End If
End Function
Private Sub Form_Open(Cancel As Integer)
Dim MyDb As Database
Dim SQLStg As String
Dim RecCount As Long
Set MyDb = CurrenrDb
SQLStg LStg = "SELECT DISTINCTROW
IIf([Type]=5,'Queries',IIf([Type]=-32768,'Forms'," SQLStg = SQLStg &
"IIf([Type]=1,'Tables',IIf([Type]=6,'Attached Tables'," SQLStg = SQLStg &
"IIf([Type]=-32764,'Reports'))))) AS ObjectType, " SQLStg = SQLStg &
"MSysObjects.Name, " SQLStg = SQLStg &
"GetDescription([MSysObjects].[Name],[MSysObjects].[Type]) AS Description, "
SQLStg = SQLStg & "MSysObjects.Flags, InStr([Name],'Sub') AS Expr2,
MSysObjects.Type " SQLStg = SQLStg & "FROM MSysObjects "
SQLStg = SQLStg & "IN '" & MyDb.Name & "' "
SQLStg LStg = SQLStg & "WHERE (((MSysObjects.Flags) = 0 Or
(MSysObjects.Flags) = 16 " SQLStg = SQLStg & "Or (MSysObjects.Flags) = 128 "
SQLStg LStg = SQLStg & "Or (MSysObjects.Flags) = 2097152) And ((InStr([Name],
'Sub')) = 0) " SQLStg = SQLStg & "And ((MSysObjects.Type) <> 2 And
(MSysObjects.Type) <> 3 " SQLStg = SQLStg & "And (MSysObjects.Type) <> 8 And
(MSysObjects.Type) <> -32758 " SQLStg = SQLStg & "And (MSysObjects.Type) <>
-32761 And (MSysObjects.Type) <> -32757 " SQLStg = SQLStg & "And
(MSysObjects.Type) <> -32766) And ((Left([Name], 1)) <> '~'))" SQLStg =
SQLStg & "ORDER BY IIf([Type]=5,'Queries',IIf([Type]=-32768,'Forms'," SQLStg
= SQLStg & "IIf([Type]=1,'Tables',IIf([Type]=6,'Attached Tables'," SQLStg =
SQLStg & "IIf([Type]=-32764,'Reports'))))), MSysObjects.Name;"
Me.RecordSource = SQLStg
Me.RecordsetClone.MoveLast
RecCount = Me.RecordsetClone.RecordCount
End Sub
Phil
---
This email is free from viruses and malware because avast! Antivirus protection is active.
http://www.avast.com