Article ID: 141618
Article Last Modified on 1/19/2007
Function SetApplicationTitle(ByVal MyTitle As String)
If SetStartupProperty("AppTitle", dbText, MyTitle) Then
Application.RefreshTitleBar
Else
Msgbox "ERROR: Could not set Application Title"
End If
End Function
Function SetStartupProperty(prpName As String, _
prpType As Variant, prpValue As Variant) As Integer
Dim DB As DATABASE, PRP As Property, WS As Workspace
Const ERROR_PROPNOTFOUND = 3270
Set DB = CurrentDb()
' Set the startup property value.
On Error GoTo Err_SetStartupProperty
DB.Properties(prpName) = prpValue
SetStartupProperty = True
Bye_SetStartupProperty:
Exit Function
Err_SetStartupProperty:
Select Case Err
' If the property does not exist, create it and try again.
Case ERROR_PROPNOTFOUND
Set PRP = DB.CreateProperty(prpName, prpType, prpValue)
DB.Properties.Append PRP
Resume
Case Else
SetStartupProperty = False
Resume Bye_SetStartupProperty
End Select
End Function
Function CurrentMDB() As String
Dim i As Integer, FullPath As String
FullPath = CurrentDb.Name
' Search backward in string for back slash character.
For i = Len(FullPath) To 1 Step -1
' Return all characters to the right of the back slash.
If Mid(FullPath, i, 1) = "\" Then
CurrentMDB = Mid(FullPath, i + 1)
Exit Function
End If
Next i
End Function
Macro Name Action
-------------------
AutoExec Runcode
AutoExec Actions
---------------------------------------------------------------
RunCode
Function Name: =SetApplicationTitle(CurrentMDB() &" - " & _
CurrentUser)
NOTE: In the Function Name setting above, the underscore (_) at the end
of the line is used as a line-continuation character. Remove the
underscore from the end of the line when typing the Function Name setting.Keywords: kbhowto kbprogramming KB141618