The left side message box is the default style of MS-Access and the right-side one is with the use of Office Assistant. The Program uses the default Office Assistant Setting for Message Boxes. Here the Office Cat is the default setting, hence it is appearing with the Message Box. By adding a few Functions in a Global Module of your MS-Access Project will help you to make use this feature wherever you need them. Some of the very commonly used Functions are created separately for ease of use limiting the maximum Number of Parameters needed for the Functions to two and 2nd Parameter for Title is Optional and can be omitted. First Parameter for Message Text and the second one for Title. Button Type and Icon Type is already added to the Function. The following Functions are available and their usage Syntax is as follows:

 

MsgOK("Message Text","Title") – MessageBox with only OK Button

 

MsgYN("Message Text","Title") - MessageBox with Yes & No Buttons. Returned Value is vbYes or vbNo

 

MsgOKCL("Message Text","Title") - MessageBox with OK, Cancel Buttons. Returned Value is vbOK or vbCancel

 

First you must attach the Microsoft Office 9.0 Object Library (or whatever version of Office you have) to your Project. You must add other essential Library Files to your Project as well. Please refer my earlier post Title: Command-Button Animation for a List of Project Library Files and procedures to attach them to your Project. After completion of Library Files fixing copy the following Code into a Global Module and save them.

Public Function MsgOK(ByVal strmsg As String, Optional ByVal strHeading As String) As Integer
On Error resume next
MsgOK = MsgBalun(strmsg, strHeading, msoButtonSetOK, msoAnimationGestureUp, msoIconAlertInfo)
End Function

Public Function MsgOKCL(ByVal strmsg As String, Optional ByVal strHeading As String) As Integer
on error resume next
MsgOKCL = MsgBalun(strmsg, strHeading, msoButtonSetOkCancel, msoAnimationWritingNotingSomething, msoIconAlertQuery)
End Function   

Public Function MsgYN(ByVal strmsg As String, Optional ByVal strHeading As String) As Integer
on error resume next
MsgYN = MsgBalun(strmsg, strHeading, msoButtonSetYesNo, msoAnimationWritingNotingSomething, msoIconAlertQuery)
End Function   

Private Function MsgBalun(ByVal strText As String, ByVal strTitle As String, ByVal lngButtons As Long, ByVal intAnimation, ByVal intIcon) As Integer '------------------------------------------------------------
'Author : a.p.r. pillai
'Date   : September 2006
'------------------------------------------------------------
Dim lngx As Long, intVal As Integer, Balu As Balloon
On Error GoTo MsgBaloons_Err
With Assistant
If .On = False Then
    .On = True
   '.FileName = "OFFCAT.acs"
     .Animation = msoAnimationGetAttentionMinor
     .AssistWithHelp = True
     .GuessHelp = True
     .FeatureTips = False
     .Visible = True
End If
End With
  Set Balu = Assistant.NewBalloon
 With Balu
     .Animation = intAnimation
     .Icon = intIcon
    .Heading = strTitle
    .Text = strText
    .BalloonType = msoBalloonTypeButtons
    .Button = lngButtons
  Select Case Balu.Show
        Case msoBalloonButtonOK
            MsgBalun = vbOK
        Case msoBalloonButtonCancel
           MsgBalun = vbCancel
        Case msoBalloonButtonYes
           MsgBalun = vbYes
        Case msoBalloonButtonNo
           MsgBalun = vbNo
 End Select
 End With
  Assistant.Visible = False

MsgBaloons_Exit:
Exit Function  

MsgBaloons_Err:
MsgBox Err.Description, , "MsgBaloons"
Resume MsgBaloons_Exit
End Function

 

You can use these Functions without bothering about selecting the Button-Type, IconType etc. that you normally need to give along with the MessageBox Command like:

vbYesNo+vbDefaultButton2+vbQuestion

 

Usage Example:

 

If MsgYN("Select Yes to Proceed, No to Cancel.","cmdProcess") = vbYes then

 

   Docmd.runmacro "Process"

 

End if

 

OR

 

Second Parameter Title is omitted in the second example.
If MsgYN("Select Yes to Proceed, No to Cancel.") = vbYes then

 

   Docmd.runmacro "Process"

 

End if

 

MsgOK "System is preparing to Shut Down","cmdExit_Click"

 

OR

 

MsgOK "System is preparing to Shut Down"

 

The MsgBalun() Function is not directly used in programs.

 

Implement the procedures in your Project and try them out.




Download Demo Database



Create 3D Heading
Shadow 3D Heading Style
Border 2D Heading Style
Border 3D Heading Style