Refer to Database Manager value?

fearoffours

Registered User.
Local time
Today, 18:33
Joined
Apr 10, 2008
Messages
82
Anyone know if there's a way to reference the value of the field titled Manager in the Database Properties dialog? I'd like to use it in a MsgBox function, but am aware the manager might change...
 
Sorry, I'm not being clear enough.
This is not a value stored in a table within the database (though maybe this is the way forward), but the value accessed by opening the File->Database Properties dialog from within Access (2000).
 
Simple Software Solutions

Each database has its own set of properties that can be retreived in the following manor. I'm not sure what the actual property name is but here is the solution.

Code:
    Function GetManager()
        Dim DB As Database
        Set DB = DBEngine(0)(0)
        Manager= DB.Properties![?PropertyName?]
    End Function

The interesting thing is that you can fetch the copyright notice from a different database from the current one:

Code:
    Function GetManager(filename As String)
        Dim DB As Database
        Set DB = OpenDatabase(filename)
        Manager= DB.Properties![?PropertyName?]
        DB.Close
    End Function

Perhaps a function to update the Manager would be good too:

Code:
    Function ManagerUpd(filename As String)
        Dim DB As Database
        Set DB = OpenDatabase(filename)
        DB.Properties![?PropertyName?] = "Fred Blogs"
        DB.Close
    End Function

Finally as an afterthought here is a function to enumerate through your database properties collection.

Code:
Function PropertyX()

   Dim MyDB As DAO.Database
   Dim prpLoop As Property

   Set dbs = CurrentDb

   With dbs

      ' Enumerate all properties of current database.
      Debug.Print "Properties of " & .Name
      For Each prpLoop In .Properties
         With prpLoop
            Debug.Print "  " & .Name
         End With
      Next prpLoop

   End With

End Function


CodeMaster::cool:
 
WOW, awesome amount of help! Thanks very much! Will endeavour to put it to good use when back at the desk tomorrow!
 
I don't think there is a 'manager' db property is there?
 
Simple Software Solutions

Not sure:confused: never had the need to use this property.

David
 
Unfortunately David's initial method didn't work, it couldn't find the property titled 'Manager'. So Ken, as you said, there is no Property titled Manager.

However, a search in the Help Files for Database Properties (I hadn't really known what to search for previously!) yielded the following code:
Code:
Public Function GetSummaryInfo(strPropName As String) As String
    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
    Set dbs = CurrentDb
    Set cnt = dbs.Containers!Databases
    Set doc = cnt.Documents!SummaryInfo
    doc.Properties.Refresh
    GetSummaryInfo = doc.Properties(strPropName)

GetSummary_Bye:
    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
This gets any info from the 'Summary' Tab of the Database Properties dialog.

And then GetSummaryInfo("Manager") returns the expected Value.

Thanks for your help everyone.
 
Last edited:
Maybe I'm missing something then - Whats the point in checking the db properties then?
 
Cool - Learn something new everyday. Thanks fear - :)
 
So if you put a name in the 'Manager' field then you can retreive it with this:

currentdb.Containers(1).Documents(2).Properties("Manager")

If it's not there you can trap it with error 3270
 
So if you put a name in the 'Manager' field then you can retreive it with this:

currentdb.Containers(1).Documents(2).Properties("Manager")

If it's not there you can trap it with error 3270
Thanks Ken.
What advantages does this method have over the one listed in my previous post?
I can see that it's shorter in total amount of code necessary. Isn't having to use numeric constants is a bit ugly though?

And are there any recommended posts/pther reading on error handling?
 
The primary upside to your code is that its portable. By that I mean you can put it in a generic module and use it to get any of the properties for that object simply by passing it the property name. My example is kind of like hard coding which is usually frowned on. The other upside to your sample code is that using it gives invaluable experience using objects. But if all you do is cut and paste it and don't understand exactly what its doing then its not helping a lot...
 
...The other upside to your sample code is that using it gives invaluable experience using objects. But if all you do is cut and paste it and don't understand exactly what its doing then its not helping a lot...
Agreed on both counts!
I try not to copy and paste completely willy-nilly. (Although the above sample is verbatim from the helpfile with the addition of the initial 'Public'!) I recognise the only way I'll ever improve is by deconstructing what I copy/paste.
I've probably learnt more that way than from reading the one book on Access 97 VBA that I struggled with 8-9 years ago when I first tried (unsuccessfully) to code a database.
Since then I've learnt about the basic concepts and terminology of programming from a variety of other sources, so this time round I'm much more aware of what I'm doing, and it goes without saying this forum has helped a lot.

I find using objects to frequently be a stumbling block at the moment, but I can understand what's happening in that function, particularly when I can compare it with the code you provided above.
I wanted to make sure I wasn't missing anything further in relation to advantages of one method over the other.
 

Users who are viewing this thread

Back
Top Bottom