Dear Tipmasters:
I would like to get at the "Database Properties" that you see when you select file>>Database>>Properties>>Summary menu items. I would like to use an ADO hierarchy but this may be above that in the "workspace" that I do not understand very vell. I have some code in DAO that works but can not convert it. Help is appreciated on the conversion.
Existing DAO Code:
Function GetSummaryInfo(strPropName As String, Optional varFileName As Variant) As String
' Comments: Get "Summary" properties of Database. Taken
' from Access97 help file.
' Parameters: strPropName = Name of property
' Return: "None" is returned if the property hasn't already been set.
' If an unknown error occurs, a zero-length string (" ") is returned.
' Dependencies: None
' Created: 9/15/00 MAW
' Modified:6/19/01 SDK to accept varFileName as additional arg. to work with external db's.
'
' --------------------------------------------------------
Dim dbs As Database, cnt As Container
Dim doc As Document, prp As Property
' Property not found error.
Const conPropertyNotFound = 3270
On Error GoTo GetSummary_Err
If IsMissing(varFileName) Then
Set dbs = CurrentDb
Else
On Error Resume Next
Set dbs = DBEngine.OpenDatabase(varFileName)
If Err <> 0 Then
GetSummaryInfo = ""
GoTo GetSummary_Bye
End If
End If
Set cnt = dbs.Containers!Databases
Set doc = cnt.Documents!SummaryInfo
doc.Properties.Refresh
GetSummaryInfo = doc.Properties(strPropName)
GetSummary_Bye:
Set dbs = Nothing
Set cnt = Nothing
Set doc = Nothing
Exit Function
GetSummary_Err:
If Err = conPropertyNotFound Then
Set prp = doc.CreateProperty(strPropName, dbText, "None")
' Append to collection.
doc.Properties.Append prp
Resume
Else
' Unknown error.
GetSummaryInfo = ""
Resume GetSummary_Bye
End If
End Function
I would like to get at the "Database Properties" that you see when you select file>>Database>>Properties>>Summary menu items. I would like to use an ADO hierarchy but this may be above that in the "workspace" that I do not understand very vell. I have some code in DAO that works but can not convert it. Help is appreciated on the conversion.
Existing DAO Code:
Function GetSummaryInfo(strPropName As String, Optional varFileName As Variant) As String
' Comments: Get "Summary" properties of Database. Taken
' from Access97 help file.
' Parameters: strPropName = Name of property
' Return: "None" is returned if the property hasn't already been set.
' If an unknown error occurs, a zero-length string (" ") is returned.
' Dependencies: None
' Created: 9/15/00 MAW
' Modified:6/19/01 SDK to accept varFileName as additional arg. to work with external db's.
'
' --------------------------------------------------------
Dim dbs As Database, cnt As Container
Dim doc As Document, prp As Property
' Property not found error.
Const conPropertyNotFound = 3270
On Error GoTo GetSummary_Err
If IsMissing(varFileName) Then
Set dbs = CurrentDb
Else
On Error Resume Next
Set dbs = DBEngine.OpenDatabase(varFileName)
If Err <> 0 Then
GetSummaryInfo = ""
GoTo GetSummary_Bye
End If
End If
Set cnt = dbs.Containers!Databases
Set doc = cnt.Documents!SummaryInfo
doc.Properties.Refresh
GetSummaryInfo = doc.Properties(strPropName)
GetSummary_Bye:
Set dbs = Nothing
Set cnt = Nothing
Set doc = Nothing
Exit Function
GetSummary_Err:
If Err = conPropertyNotFound Then
Set prp = doc.CreateProperty(strPropName, dbText, "None")
' Append to collection.
doc.Properties.Append prp
Resume
Else
' Unknown error.
GetSummaryInfo = ""
Resume GetSummary_Bye
End If
End Function