Oorang
03-20-2009, 04:40 PM
Hello All you Access-Ninjas:)
This if for a knowledge base article when the KB is backup, but I thought I'd like to open it up for some public feedback in the mean time.
As a lot of you know, older version of Access used to give you the pretty formatted MsgBox that would also roll over to the Office Assistant if it was turned on. And then in Office 2000 it all went away:( A long time ago Michael Kaplan figured out how to restore the formatted MsgBox syntax (http://www.mvps.org/access/bugs/bugs0035.htm) but to the best of my knowledge, no one has offered a way to bring back the office assistant.
A coworker and I were joking around about the Office Assistant and I confessed my secret shame. I always kind of liked the Office Assistant. And to my suprise I found that he did to. So I started asking around and discovered to about 8 out of 10 people were willing to admit that they liked it.
So I decided to bring it back.
The following code is very simple to implement. You simply have to import into a project, and all calls to MsgBox from anywhere in the project (including your already written code) will be intercepted. If the assistant is on and displayalerts is enabled, then your question/message will be presented through the assistant. If the assistant is off (as it probably will be a lot) then it will attempt to use the Formatted Access MsgBox. And finally failing all that will use the plain vanilla MsgBox.
All the inputs and outputs should be the same so to test this out, your really just need to import it. (If you use it in non-access applications for Office Assistant support make sure you set the constants at the top of the module accordingly.) It's all remarked up already because even though I did it on my own time, I intend to use in for work.
So anywho... I need a volunteer : pray2:
'-------------------------------------------------------------------------------
' Copyright : Free for public use, no rights reserved.
' Credit :
' - Aaron Bush for Office Assistant Piece
' - Michael Kaplan for Access Formatted MsgBox piece.
' - You: If you add/change improve this code... feel free to take some credit
' too:)
' Module Purpose : Importing module into a project will intercept all calls
' MsgBox and route them through the Office Assistant when
' is on, or failing that will present the message in
' Access Formated MsgBox format.
' Implementation : No modification of already existing code is needed as
' all inputs/outputs will match MsgBoxes. You simply need
' to import the module for it to work.
' Note1: This module will provide support for the Office
' Assistant in Non-Access Office Applications if
' you set the compiler constant
' "ccSupportAccessMsgBoxes" to 0.
' Note2: If you don't want to support the Office Assistant
' you can set the compiler constant
' "ccSupportOfficeAssistant" to 0 and it will not
' be used. In addition setting said reference to
' 0 will remove the need to have a project
' reference to Microsoft Office.
' Module Dependancies : None.
' Module References :
' - Visual Basic For Applications
' C:\Program Files\Common Files\Microsoft Shared\VBA\VBA6\VBE6.DLL
' - *Microsoft Access Object Library
' C:\Program Files\Microsoft Office\OFFICE11\MSACCESS.EXE
' * Only if compiler constant ccSupportAccessMsgBoxes is true.
'-------------------------------------------------------------------------------
' Revisions:
'-------------------------------------------------------------------------------
' Version 1.11 Aaron Bush 03/21/2009
'-------------------------------------------------------------------------------
' Corrected bug that was looking for 3 "@"s instead of 2 as the condition to use
' the Access MessageBox format.
'-------------------------------------------------------------------------------
' Version 1.10 Aaron Bush 03/20/2009
'-------------------------------------------------------------------------------
' Added Support for Access Formatted Message Boxes.
'-------------------------------------------------------------------------------
' Version 1.00 Aaron Bush 03/13/2009
'-------------------------------------------------------------------------------
' Creation.
'-------------------------------------------------------------------------------
Option Explicit
Option Base 0
Option Compare Binary
Option Private Module
'Be sure to recompile if you change these values (0 for false, -1 for true):
#Const ccSupportOfficeAssistant = -1
#Const ccSupportAccessMsgBoxes = -1
#Const ccDebugMode = 0
'Used in error handling, etc:
Private Const m_strModuleName_c As String = "mdlAccessMsgBox"
#If ccDebugMode Then
Public Sub TestMsgBox()
'Just for testing:
MsgBox "foo@bar@baz"
MsgBox "foo@bar@baz", vbInformation, vbNullString
End Sub
#End If
Public Function MsgBox(ByVal prompt As String, _
Optional ByVal buttons As VbMsgBoxStyle, _
Optional ByVal title As Variant, _
Optional ByVal helpFile As Variant, _
Optional ByVal context As Variant) As VbMsgBoxResult
'---------------------------------------------------------------------------
' Original Author : Aaron Bush
' Date of Creation : 03/13/2009
'---------------------------------------------------------------------------
' Purpose : Adds support for the Office Assistant by presenting your
' messsage boxes via the Office Assistant. Will only present
' assistant if assistant is:
' - On.
' - The "Assist With Alerts" option has been checked.
' Otherwise a normal message box will be displayed.
' (See module header for more detail.)
' Input(s) : Same as standard VBA.MsgBox.
' Output(s) : Same as standard VBA.MsgBox
' Remarks : - Untested on Office 12.0 and Greater so will not attempt to
' use the Office Assistant in versions greater than 11.0.
' - Msgbox calls using the help button cannot be be displayed via
' the assistant and will be displayed in a normal messagebox.
' - *******IMPORTANT*******
' Placing this code in a project will cause the code to
' intercept all calls using the MsgBox method.
' - You can force a MsgBox call to ignore this method by
' prefixing the call with VBA (Ex: VBA.MsgBox "Hello World!").
' Revisions :
' 03/16/2009 Aaron Bush
' - Put in version check.
' - Added Error Handler.
' - Changed parameters to variants so when the arguments are "Missing"
' the system will use the correct default title.
' 03/20/2009 Aaron Bush
' - Merged with function for supporting Access Formatted MsgBoxes.
'---------------------------------------------------------------------------
Const strProcedureName_c As String = "MsgBox"
Const dblMaxVer_c As Double = 11#
Dim eRtnVal As VbMsgBoxResult
Dim blnUseAst As Boolean
Dim strTitle As String
'If we aren't supporting the Office Assistant no point in burning memory:
#If ccSupportOfficeAssistant Then
Dim ast As Office.Assistant
Dim eBtnType As Office.MsoAlertButtonType
Dim eAlrtIconType As Office.MsoAlertIconType
Dim eDfltBtn As Office.MsoAlertDefaultType
#End If
'Don't invoke the error handler in debug mode:
#If Not ccDebugMode Then
On Error GoTo Err_Hnd
#End If
'Neither the Access.Eval method, nor the Office.Assistant.DoAlert method
'support Variants with the value "Missing". This will prevent an exception
'from being thrown and approximatly mimick the default titles MsgBox would
'normally provide.
If IsMissing(title) Then
strTitle = GetAppTitle
Else
strTitle = title
End If
'If we are supporting the office assistant, a few basic tests still need to
'be run before using it:
#If ccSupportOfficeAssistant Then
'Don't run for for unsupport versions:
If Val(Application.Version) <= dblMaxVer_c Then
'Help features are not available for the assistant:
If (buttons And vbMsgBoxHelpButton) <> vbMsgBoxHelpButton Then
'Get application's Office Assistant:
Set ast = Application.Assistant
'Check to see if assistant is on, and enabled for alerts.
If ast.On And ast.AssistWithAlerts And ast.Visible Then
'All tests passed. Flag assistant to be used:
blnUseAst = True
'Unpack values in "buttons" parameter to their Office Assistant
'equivalents:
eBtnType = MsgBoxStyleToButtonType(buttons)
eAlrtIc eDfltBtn = MsgBoxStyleToDefaultType(buttons)
End If
End If
End If
#End If
#If ccSupportOfficeAssistant Then
'If we are using the assistant then:
If blnUseAst Then
'Get rid of the "@"s.
prompt = Replace(prompt, "@", vbNewLine & vbNewLine, compare:=vbBinaryCompare)
'Do Assistant prompt:
eRtnVal = ast.DoAlert(strTitle, prompt, eBtnType, eAlrtIconType, _
eDfltBtn, msoAlertCancelDefault, False)
Else
'We are not using the assistant:
#End If
'If we are supporting Access Formatted Message Boxes then use them:
#If ccSupportAccessMsgBoxes Then
If CountInStr(prompt, "@") = 2 Then
eRtnVal = FormattedMsgBox(prompt, buttons, strTitle, helpFile, context)
Else
#End If
'Otherwise, force a normal prompt by specifying the library:
eRtnVal = VBA.MsgBox(prompt, buttons, strTitle, helpFile, context)
#If ccSupportAccessMsgBoxes Then
End If
#End If
#If ccSupportOfficeAssistant Then
End If
#End If
Exit_Proc:
On Error Resume Next
'Set Return Value:
MsgBox = eRtnVal
#If ccSupportOfficeAssistant Then
'Release Objects/Arrays:
Set ast = Nothing
#End If
'If not in debug mode we need an error handler in the unlikely event of an
'error.
#If Not ccDebugMode Then
Exit Function
Err_Hnd:
VBA.MsgBox Err.Description, vbCritical + vbApplicationModal _
+ vbMsgBoxSetForeground, _
Err.Source & "." & m_strModuleName_c & "." & strProcedureName_c & ": " _
& Err.Number
Resume Exit_Proc
Resume
#End If
End Function
#If ccSupportOfficeAssistant Then
Private Function MsgBoxStyleToButtonType(ByVal value As VBA.VbMsgBoxStyle _
) As Office.MsoAlertButtonType
Dim eRtnVal As Office.MsoAlertButtonType
If (value And vbRetryCancel) = vbRetryCancel Then '4+1
eRtnVal = msoAlertButtonRetryCancel
ElseIf (value And vbYesNoCancel) = vbYesNoCancel Then '2+1
eRtnVal = msoAlertButtonYesNoCancel
ElseIf (value And vbAbortRetryIgnore) = vbAbortRetryIgnore Then '2
eRtnVal = msoAlertButtonAbortRetryIgnore
ElseIf (value And vbOKCancel) = vbOKCancel Then '1
eRtnVal = msoAlertButtonOKCancel
ElseIf (value And vbYesNo) = vbYesNo Then '4
eRtnVal = msoAlertButtonYesNo
End If
MsgBoxStyleToButt End Function
Private Function MsgBoxStyleToIconType(ByVal value As VBA.VbMsgBoxStyle _
) As Office.MsoAlertIconType
Dim eRtnVal As Office.MsoAlertIconType
If (value And vbExclamation) = vbExclamation Then '32+16
eRtnVal = msoAlertIconWarning
ElseIf (value And vbInformation) = vbInformation Then '64
eRtnVal = msoAlertIconInfo
ElseIf (value And vbQuestion) = vbQuestion Then '32
eRtnVal = msoAlertIconQuery
ElseIf (value And vbCritical) = vbCritical Then '16
eRtnVal = msoAlertIconCritical
End If
MsgBoxStyleToIc End Function
Private Function MsgBoxStyleToDefaultType(ByVal value As VBA.VbMsgBoxStyle _
) As Office.MsoAlertDefaultType
Dim eRtnVal As Office.MsoAlertIconType
If (value And vbDefaultButton4) = vbDefaultButton4 Then '512+256
eRtnVal = msoAlertDefaultFourth
ElseIf (value And vbDefaultButton2) = vbDefaultButton2 Then '256
eRtnVal = msoAlertDefaultSecond
ElseIf (value And vbDefaultButton3) = vbDefaultButton3 Then '512
eRtnVal = msoAlertDefaultThird
End If
MsgBoxStyleToDefaultType = eRtnVal
End Function
#End If
#If ccSupportAccessMsgBoxes Then
Private Function FormattedMsgBox(ByVal prompt As String, _
Optional ByVal buttons As VbMsgBoxStyle, _
Optional ByVal title As Variant, _
Optional ByVal helpFile As Variant, _
Optional ByVal context As Variant) As VbMsgBoxResult
'Credit to Michael Kaplan for this piece
'http://www.mvps.org/access/bugs/bugs0035.htm
If IsMissing(helpFile) Or IsMissing(context) Then
FormattedMsgBox = Eval("MsgBox(""" & prompt & _
""", " & buttons & ", """ & title & """)")
Else
FormattedMsgBox = Eval("MsgBox(""" & prompt & _
""", " & buttons & ", """ & title & """, """ & _
helpFile & """, " & context & ")")
End If
End Function
#End If
Private Function GetAppTitle() As String
#If ccSupportAccessMsgBoxes Then
Dim strRtnVal As String
'Reading the AppTitle property when there is no title defined will throw an
'error. This will supress that.
On Error Resume Next
strRtnVal = CurrentDb.Properties("AppTitle").value
'If we didn't get a title then just use
If LenB(strRtnVal) = 0 Then
strRtnVal = "Microsoft Office Access"
End If
GetAppTitle = strRtnVal
#Else
GetAppTitle = Application.Name
#End If
End Function
Private Function CountInStr(ByVal value As String, ByVal count As String) As Long
CountInStr = Len(value) - _
Len(Replace(value, count, vbNullString, compare:=vbBinaryCompare))
End Function
This if for a knowledge base article when the KB is backup, but I thought I'd like to open it up for some public feedback in the mean time.
As a lot of you know, older version of Access used to give you the pretty formatted MsgBox that would also roll over to the Office Assistant if it was turned on. And then in Office 2000 it all went away:( A long time ago Michael Kaplan figured out how to restore the formatted MsgBox syntax (http://www.mvps.org/access/bugs/bugs0035.htm) but to the best of my knowledge, no one has offered a way to bring back the office assistant.
A coworker and I were joking around about the Office Assistant and I confessed my secret shame. I always kind of liked the Office Assistant. And to my suprise I found that he did to. So I started asking around and discovered to about 8 out of 10 people were willing to admit that they liked it.
So I decided to bring it back.
The following code is very simple to implement. You simply have to import into a project, and all calls to MsgBox from anywhere in the project (including your already written code) will be intercepted. If the assistant is on and displayalerts is enabled, then your question/message will be presented through the assistant. If the assistant is off (as it probably will be a lot) then it will attempt to use the Formatted Access MsgBox. And finally failing all that will use the plain vanilla MsgBox.
All the inputs and outputs should be the same so to test this out, your really just need to import it. (If you use it in non-access applications for Office Assistant support make sure you set the constants at the top of the module accordingly.) It's all remarked up already because even though I did it on my own time, I intend to use in for work.
So anywho... I need a volunteer : pray2:
'-------------------------------------------------------------------------------
' Copyright : Free for public use, no rights reserved.
' Credit :
' - Aaron Bush for Office Assistant Piece
' - Michael Kaplan for Access Formatted MsgBox piece.
' - You: If you add/change improve this code... feel free to take some credit
' too:)
' Module Purpose : Importing module into a project will intercept all calls
' MsgBox and route them through the Office Assistant when
' is on, or failing that will present the message in
' Access Formated MsgBox format.
' Implementation : No modification of already existing code is needed as
' all inputs/outputs will match MsgBoxes. You simply need
' to import the module for it to work.
' Note1: This module will provide support for the Office
' Assistant in Non-Access Office Applications if
' you set the compiler constant
' "ccSupportAccessMsgBoxes" to 0.
' Note2: If you don't want to support the Office Assistant
' you can set the compiler constant
' "ccSupportOfficeAssistant" to 0 and it will not
' be used. In addition setting said reference to
' 0 will remove the need to have a project
' reference to Microsoft Office.
' Module Dependancies : None.
' Module References :
' - Visual Basic For Applications
' C:\Program Files\Common Files\Microsoft Shared\VBA\VBA6\VBE6.DLL
' - *Microsoft Access Object Library
' C:\Program Files\Microsoft Office\OFFICE11\MSACCESS.EXE
' * Only if compiler constant ccSupportAccessMsgBoxes is true.
'-------------------------------------------------------------------------------
' Revisions:
'-------------------------------------------------------------------------------
' Version 1.11 Aaron Bush 03/21/2009
'-------------------------------------------------------------------------------
' Corrected bug that was looking for 3 "@"s instead of 2 as the condition to use
' the Access MessageBox format.
'-------------------------------------------------------------------------------
' Version 1.10 Aaron Bush 03/20/2009
'-------------------------------------------------------------------------------
' Added Support for Access Formatted Message Boxes.
'-------------------------------------------------------------------------------
' Version 1.00 Aaron Bush 03/13/2009
'-------------------------------------------------------------------------------
' Creation.
'-------------------------------------------------------------------------------
Option Explicit
Option Base 0
Option Compare Binary
Option Private Module
'Be sure to recompile if you change these values (0 for false, -1 for true):
#Const ccSupportOfficeAssistant = -1
#Const ccSupportAccessMsgBoxes = -1
#Const ccDebugMode = 0
'Used in error handling, etc:
Private Const m_strModuleName_c As String = "mdlAccessMsgBox"
#If ccDebugMode Then
Public Sub TestMsgBox()
'Just for testing:
MsgBox "foo@bar@baz"
MsgBox "foo@bar@baz", vbInformation, vbNullString
End Sub
#End If
Public Function MsgBox(ByVal prompt As String, _
Optional ByVal buttons As VbMsgBoxStyle, _
Optional ByVal title As Variant, _
Optional ByVal helpFile As Variant, _
Optional ByVal context As Variant) As VbMsgBoxResult
'---------------------------------------------------------------------------
' Original Author : Aaron Bush
' Date of Creation : 03/13/2009
'---------------------------------------------------------------------------
' Purpose : Adds support for the Office Assistant by presenting your
' messsage boxes via the Office Assistant. Will only present
' assistant if assistant is:
' - On.
' - The "Assist With Alerts" option has been checked.
' Otherwise a normal message box will be displayed.
' (See module header for more detail.)
' Input(s) : Same as standard VBA.MsgBox.
' Output(s) : Same as standard VBA.MsgBox
' Remarks : - Untested on Office 12.0 and Greater so will not attempt to
' use the Office Assistant in versions greater than 11.0.
' - Msgbox calls using the help button cannot be be displayed via
' the assistant and will be displayed in a normal messagebox.
' - *******IMPORTANT*******
' Placing this code in a project will cause the code to
' intercept all calls using the MsgBox method.
' - You can force a MsgBox call to ignore this method by
' prefixing the call with VBA (Ex: VBA.MsgBox "Hello World!").
' Revisions :
' 03/16/2009 Aaron Bush
' - Put in version check.
' - Added Error Handler.
' - Changed parameters to variants so when the arguments are "Missing"
' the system will use the correct default title.
' 03/20/2009 Aaron Bush
' - Merged with function for supporting Access Formatted MsgBoxes.
'---------------------------------------------------------------------------
Const strProcedureName_c As String = "MsgBox"
Const dblMaxVer_c As Double = 11#
Dim eRtnVal As VbMsgBoxResult
Dim blnUseAst As Boolean
Dim strTitle As String
'If we aren't supporting the Office Assistant no point in burning memory:
#If ccSupportOfficeAssistant Then
Dim ast As Office.Assistant
Dim eBtnType As Office.MsoAlertButtonType
Dim eAlrtIconType As Office.MsoAlertIconType
Dim eDfltBtn As Office.MsoAlertDefaultType
#End If
'Don't invoke the error handler in debug mode:
#If Not ccDebugMode Then
On Error GoTo Err_Hnd
#End If
'Neither the Access.Eval method, nor the Office.Assistant.DoAlert method
'support Variants with the value "Missing". This will prevent an exception
'from being thrown and approximatly mimick the default titles MsgBox would
'normally provide.
If IsMissing(title) Then
strTitle = GetAppTitle
Else
strTitle = title
End If
'If we are supporting the office assistant, a few basic tests still need to
'be run before using it:
#If ccSupportOfficeAssistant Then
'Don't run for for unsupport versions:
If Val(Application.Version) <= dblMaxVer_c Then
'Help features are not available for the assistant:
If (buttons And vbMsgBoxHelpButton) <> vbMsgBoxHelpButton Then
'Get application's Office Assistant:
Set ast = Application.Assistant
'Check to see if assistant is on, and enabled for alerts.
If ast.On And ast.AssistWithAlerts And ast.Visible Then
'All tests passed. Flag assistant to be used:
blnUseAst = True
'Unpack values in "buttons" parameter to their Office Assistant
'equivalents:
eBtnType = MsgBoxStyleToButtonType(buttons)
eAlrtIc eDfltBtn = MsgBoxStyleToDefaultType(buttons)
End If
End If
End If
#End If
#If ccSupportOfficeAssistant Then
'If we are using the assistant then:
If blnUseAst Then
'Get rid of the "@"s.
prompt = Replace(prompt, "@", vbNewLine & vbNewLine, compare:=vbBinaryCompare)
'Do Assistant prompt:
eRtnVal = ast.DoAlert(strTitle, prompt, eBtnType, eAlrtIconType, _
eDfltBtn, msoAlertCancelDefault, False)
Else
'We are not using the assistant:
#End If
'If we are supporting Access Formatted Message Boxes then use them:
#If ccSupportAccessMsgBoxes Then
If CountInStr(prompt, "@") = 2 Then
eRtnVal = FormattedMsgBox(prompt, buttons, strTitle, helpFile, context)
Else
#End If
'Otherwise, force a normal prompt by specifying the library:
eRtnVal = VBA.MsgBox(prompt, buttons, strTitle, helpFile, context)
#If ccSupportAccessMsgBoxes Then
End If
#End If
#If ccSupportOfficeAssistant Then
End If
#End If
Exit_Proc:
On Error Resume Next
'Set Return Value:
MsgBox = eRtnVal
#If ccSupportOfficeAssistant Then
'Release Objects/Arrays:
Set ast = Nothing
#End If
'If not in debug mode we need an error handler in the unlikely event of an
'error.
#If Not ccDebugMode Then
Exit Function
Err_Hnd:
VBA.MsgBox Err.Description, vbCritical + vbApplicationModal _
+ vbMsgBoxSetForeground, _
Err.Source & "." & m_strModuleName_c & "." & strProcedureName_c & ": " _
& Err.Number
Resume Exit_Proc
Resume
#End If
End Function
#If ccSupportOfficeAssistant Then
Private Function MsgBoxStyleToButtonType(ByVal value As VBA.VbMsgBoxStyle _
) As Office.MsoAlertButtonType
Dim eRtnVal As Office.MsoAlertButtonType
If (value And vbRetryCancel) = vbRetryCancel Then '4+1
eRtnVal = msoAlertButtonRetryCancel
ElseIf (value And vbYesNoCancel) = vbYesNoCancel Then '2+1
eRtnVal = msoAlertButtonYesNoCancel
ElseIf (value And vbAbortRetryIgnore) = vbAbortRetryIgnore Then '2
eRtnVal = msoAlertButtonAbortRetryIgnore
ElseIf (value And vbOKCancel) = vbOKCancel Then '1
eRtnVal = msoAlertButtonOKCancel
ElseIf (value And vbYesNo) = vbYesNo Then '4
eRtnVal = msoAlertButtonYesNo
End If
MsgBoxStyleToButt End Function
Private Function MsgBoxStyleToIconType(ByVal value As VBA.VbMsgBoxStyle _
) As Office.MsoAlertIconType
Dim eRtnVal As Office.MsoAlertIconType
If (value And vbExclamation) = vbExclamation Then '32+16
eRtnVal = msoAlertIconWarning
ElseIf (value And vbInformation) = vbInformation Then '64
eRtnVal = msoAlertIconInfo
ElseIf (value And vbQuestion) = vbQuestion Then '32
eRtnVal = msoAlertIconQuery
ElseIf (value And vbCritical) = vbCritical Then '16
eRtnVal = msoAlertIconCritical
End If
MsgBoxStyleToIc End Function
Private Function MsgBoxStyleToDefaultType(ByVal value As VBA.VbMsgBoxStyle _
) As Office.MsoAlertDefaultType
Dim eRtnVal As Office.MsoAlertIconType
If (value And vbDefaultButton4) = vbDefaultButton4 Then '512+256
eRtnVal = msoAlertDefaultFourth
ElseIf (value And vbDefaultButton2) = vbDefaultButton2 Then '256
eRtnVal = msoAlertDefaultSecond
ElseIf (value And vbDefaultButton3) = vbDefaultButton3 Then '512
eRtnVal = msoAlertDefaultThird
End If
MsgBoxStyleToDefaultType = eRtnVal
End Function
#End If
#If ccSupportAccessMsgBoxes Then
Private Function FormattedMsgBox(ByVal prompt As String, _
Optional ByVal buttons As VbMsgBoxStyle, _
Optional ByVal title As Variant, _
Optional ByVal helpFile As Variant, _
Optional ByVal context As Variant) As VbMsgBoxResult
'Credit to Michael Kaplan for this piece
'http://www.mvps.org/access/bugs/bugs0035.htm
If IsMissing(helpFile) Or IsMissing(context) Then
FormattedMsgBox = Eval("MsgBox(""" & prompt & _
""", " & buttons & ", """ & title & """)")
Else
FormattedMsgBox = Eval("MsgBox(""" & prompt & _
""", " & buttons & ", """ & title & """, """ & _
helpFile & """, " & context & ")")
End If
End Function
#End If
Private Function GetAppTitle() As String
#If ccSupportAccessMsgBoxes Then
Dim strRtnVal As String
'Reading the AppTitle property when there is no title defined will throw an
'error. This will supress that.
On Error Resume Next
strRtnVal = CurrentDb.Properties("AppTitle").value
'If we didn't get a title then just use
If LenB(strRtnVal) = 0 Then
strRtnVal = "Microsoft Office Access"
End If
GetAppTitle = strRtnVal
#Else
GetAppTitle = Application.Name
#End If
End Function
Private Function CountInStr(ByVal value As String, ByVal count As String) As Long
CountInStr = Len(value) - _
Len(Replace(value, count, vbNullString, compare:=vbBinaryCompare))
End Function