Application Title as text box?

matt beamish

Registered User.
Local time
Today, 04:41
Joined
Sep 21, 2000
Messages
215
Hi database people,

I would like to use a Database's "Application Title" (File, Options, Current Database) in a text box on a Form.

For front end path I use
Code:
=[CurrentProject].[FullName]
and for the Back end I use
Code:
=GetBEPath("tbl_name")

and I thought it'd be useful to Code in the database descriptive title too.
Have done some searching but not found much reference to this piece of information.

thanks
 
I found this
Code:
Public Function SetAppTitle(strPropValue As String) As Boolean
On Error GoTo ErrHandle

    Dim db As DAO.Database
    Dim doc As DAO.Document
    Dim prp As DAO.Property

    Set db = CurrentDb

    Set doc = db.Containers!Databases.Documents!MSysDb
    doc.Properties.Refresh

    Set prp = doc.Properties("AppTitle")
    prp.Value = strPropValue

    SetAppTitle = True

ExitHere:
    On Error Resume Next
    'Show the change on the Title Bar
    Application.RefreshTitleBar
    Set prp = Nothing
    Set doc = Nothing
    Set db = Nothing
    Exit Function

ErrHandle:
    'If property not found, create it.
    If Err = 3270 Then
        Set prp = db.CreateProperty("AppTitle", dbText, strPropValue)
        db.Containers!Databases.Documents!MSysDb.Properties.Append prp
        SetAppTitle = True
    Else
        MsgBox "Error #" & Err.Number & " " & Err.Description _
        & "In Procedure SetAppTitle"
    End If
    Resume ExitHere

End Function

Obv this is not exactly what you needed, but you should be able to reverse engineer. Rather than setting a property you can display it.
 
Thanks very much. I added this module to my Path retrieving function :
Public Function GetDBAppTitle() As String
Dim db As Database
Set db = CurrentDb
GetDBAppTitle = db.Properties("AppTitle")
End Function

and then in a Text box on my Open Menu added the Data source
=GetDBAppTitle()

This does what I want. I don't do this stuff very much, so I am pleased. If I written anything that should be corrected/improved please anyone correct away.

Thanks again
 

Users who are viewing this thread

Back
Top Bottom