The MsgBox function has an optional parameter, "Title", that allows you define the caption of the message box. However, if the Title is omitted, then Microsoft applies a default value.
|Access Version||VBA Displays||Macro Displays|
|97, 2000, 2002||Microsoft Access||Microsoft Access|
|2003, 2007||Microsoft Office Access||Microsoft Office Access|
In Access 97, if you specify an Application Title under the Tools->Startup menu, this value appears in the caption of the MsgBox function if there is no value specified for the "Title" parameter. This is a nice feature because it allows a centralized location to apply the title to all MsgBox functions throughout the application.
However, starting with Access 2000 and through Access 2007 (current version), this functionality changed. Even if you specify the Application Title, this is not displayed if the "Title" parameter is missing from the MsgBox function.
This is important to know if you are converting an Access 97 application to a newer version of Access. So, the question now is, where do we go from here?
Here is a working example to illustrate the new concepts to apply.
Public Const gcstrAppTitle As String = "Attention" Public Function GetAppTitle() As String Dim strReturnValue As String On Error Resume Next ' If there is no value in the Application Title, Access will cause an error. ' Because there is a custom, default property in place, we can skip the error. strReturnValue = CurrentDb.Properties("AppTitle") If strReturnValue = "" Then strReturnValue = gcstrAppTitle End If GetAppTitle = strReturnValue End Function Public Sub MsgBoxInfo(ByVal strPrompt As String, Optional ByVal strTitle As String) If strTitle <> "" Then MsgBox Prompt:=strPrompt, Buttons:=vbInformation, Title:=strTitle Else MsgBox Prompt:=strPrompt, Buttons:=vbInformation, Title:=GetAppTitle() End If End Sub Public Sub Main() ' Run this to see the sample MsgBoxInfo "Hello World" MsgBoxInfo "Hello World", "My Title" End Sub
Thank you! Thank you! I just finished reading this document, which was part of a link in the recent Buzz newsletter. I have printed it for others to read, especially those skeptical on the powers of Access and its capabilities.