
iterating database properties?
Well, here's an example that works. It seems to only fail on the Connection
property, which must be some non-printable type, perhaps an object of some
kind.
What it doesn't do is return the really informative stuff, like the
comments, creator, the things one can enter in the "General", "Summary",
"Statistics", "Contents", "Custom" tabs - especially Custom and Summary -
when one looks at the database properties dialog. Can one retrieve any of
things? Are they available in a container?
Thanks again.
'code begins:
'------------------
Public Function listDBproperties(Optional DBName As Variant = "*", Optional
log As Boolean = False, Optional logFile As Variant = "*")
'what one might want to do:
'load it into an array or collection
'write it to the debug window
'write it to a file
On Error GoTo Error
logFile = trim(logFile)
DBName = trim(DBName)
Dim DB As Database
If DBName = "*" Then
Set DB = CurrentDb
Else
'set the database to the specified file; one might want
error-handling here:
Set DB = Workspaces(0).OpenDatabase(DBName, , True)
End If
Dim prop As Property
Dim propString As String
Debug.Print: Debug.Print
Debug.Print "Properties in " & CurrentDb.Name & ":"
Debug.Print
If logFile <> "*" And log Then
Dim fn As Long
fn = FreeFile
Open logFile For Output As #fn
For Each prop In DB.Properties
propString = prop.Name & "="
'*MUST* be split into 2 lines for RESUME NEXT to catch the name
but disregard the value
propString = propString & prop.Value
Debug.Print propString
Print #fn, propString
Next prop
Close #fn
Else
For Each prop In DB.Properties
propString = prop.Name & "="
'*MUST* be split into 2 lines for RESUME NEXT to catch the name
but disregard the value
propString = propString & prop.Value
Debug.Print propString
Next prop
End If
Debug.Print: Debug.Print
Exit Function
Error:
Select Case err.number
Case 3251
'"Operation is not supported for this type of Object."
propString = propString & "NOT AVAILABLE"
Resume Next
Case Else
err.Raise err.number
End Select
End Function