Change application startup title programatically

K

Karen Hart

Can I programatically change Tools, Startup, Application Title
(displayed name on taskbar) depending on what form is open? This is
for an mdb that is distributed as an MDE firmwide.
Tx!
 
J

Jon Lewis

Karen Hart said:
Can I programatically change Tools, Startup, Application Title
(displayed name on taskbar) depending on what form is open? This is
for an mdb that is distributed as an MDE firmwide.
Tx!

Function SetAppTitle(strAppTitle As String) As Boolean

Dim dbs As DAO.Database
Const conPropNotFoundError = 3270
Set dbs = CurrentDb
On Error GoTo SetAppTitle_Err
dbs.Properties("AppTitle") = strAppTitle
SetAppTitle = True

SetAppTitle_Exit:
Set dbs = Nothing
Exit Function

SetAppTitle_Err:
If Err = conPropNotFoundError Then
Dim prp As DAO.Property
Set prp = dbs.CreateProperty("AppTitle", dbText, strAppTitle)
dbs.Properties.Append prp
Set prp = Nothing
SetAppTitle = True
Else
SetAppTitle = False
End If
Resume SetAppTitle_Exit

End Function

HTH
 
K

Karen Hart

Function SetAppTitle(strAppTitle As String) As Boolean

    Dim dbs As DAO.Database
    Const conPropNotFoundError = 3270
    Set dbs = CurrentDb
    On Error GoTo SetAppTitle_Err
    dbs.Properties("AppTitle") = strAppTitle
    SetAppTitle = True

SetAppTitle_Exit:
    Set dbs = Nothing
    Exit Function

SetAppTitle_Err:
    If Err = conPropNotFoundError Then
        Dim prp As DAO.Property
        Set prp = dbs.CreateProperty("AppTitle", dbText, strAppTitle)
        dbs.Properties.Append prp
        Set prp = Nothing
        SetAppTitle = True
    Else
        SetAppTitle = False
    End If
    Resume SetAppTitle_Exit

End Function

HTH

Thank you. Since I know enough about VBA to get me in trouble, where
would this code go? Would I have to put it on the OnLoad property of
every form? Would I set it once somewhere when the mdb opens? Would I
close my eyes and click my heels together 3 times and...??
 
J

Jon Lewis

Store the function in a standard module (perhaps add the prefix Public
Function... to be clear that the function is available anywhere in your
database) then you can use it where you want with syntax: SetAppTitle
"MyAppTitle". Within a VBA procedure that opens (or closes) a form, in a
form's Open or Close event, at application start using an autoexec Macro
with the RunCode action etc.

HTH


Function SetAppTitle(strAppTitle As String) As Boolean

Dim dbs As DAO.Database
Const conPropNotFoundError = 3270
Set dbs = CurrentDb
On Error GoTo SetAppTitle_Err
dbs.Properties("AppTitle") = strAppTitle
SetAppTitle = True

SetAppTitle_Exit:
Set dbs = Nothing
Exit Function

SetAppTitle_Err:
If Err = conPropNotFoundError Then
Dim prp As DAO.Property
Set prp = dbs.CreateProperty("AppTitle", dbText, strAppTitle)
dbs.Properties.Append prp
Set prp = Nothing
SetAppTitle = True
Else
SetAppTitle = False
End If
Resume SetAppTitle_Exit

End Function

HTH

Thank you. Since I know enough about VBA to get me in trouble, where
would this code go? Would I have to put it on the OnLoad property of
every form? Would I set it once somewhere when the mdb opens? Would I
close my eyes and click my heels together 3 times and...??
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top