Microsoft small business knowledge base

Article ID: 242889 - Last Review: October 26, 2013 - Revision: 4.0

This article was previously published under Q242889
This article has been archived. It is offered "as is" and will no longer be updated.
Moderate: Requires basic macro, coding, and interoperability skills.

This article applies to a Microsoft Access database (.mdb) and to a Microsoft Access project (.adp).

On This Page


In Microsoft Access 2000, the at sign (@) does not provide special formatting when you use it with the MsgBox function.


The MsgBox function provided by the Microsoft Visual Basic Editor (Vbe6.dll) does not support the formatting provided by the at sign (@).


There are two possible solutions. One solution is to use the MsgBox action in a macro. The other solution is to write a user-defined function that uses the Eval function to call the MsgBox function.

Creating a Macro that Uses the MsgBox Action

  1. In the Database window, click Macros under Objects, and then click New.
  2. In the Macro window, click the arrow under Action, and then click Msgbox in the Action list.
  3. Press F6 to move the pointer to the Message box under Action Arguments.
  4. Type the following message in the Message box:
    Wrong button!@This button doesn't work.@Try another.
  5. On the File menu, click Save As, and then click OK to save the macro with the default name.
  6. On the Run menu, click Run. Note that the first line of the message is bold.

Creating the FormattedMsgBox Function

The Eval function forces the Visual Basic for Applications expression service to evaluate the MsgBox function separately from Visual Basic Editor, and therefore it is possible to take advantage of at sign formatting. The following example uses a user-defined function named FormattedMsgBox instead of the MsgBox function. To create the FormattedMsgBox function, follow these steps:
  1. Start Microsoft Access.
  2. Open the sample database Northwind.mdb.
  3. Create a new module.
  4. Add the following procedure to the module:
    Function FormattedMsgBox(Prompt As String, _
                             Optional Buttons As VbMsgBoxStyle = vbOKOnly, _
                             Optional Title As String = "Microsoft Access", _
                             Optional HelpFile As Variant, _
                             Optional Context As Variant) As VbMsgBoxResult
        Dim strMsg As String
        If IsMissing(HelpFile) Or IsMissing(Context) Then
           strMsg = "MsgBox(" & Chr(34) & Prompt & Chr(34) & ", " & Buttons & _
                     ", " & Chr(34) & Title & Chr(34) & ")"
           strMsg = "MsgBox(" & Chr(34) & Prompt & Chr(34) & ", " & Buttons & _
                     ", " & Chr(34) & Title & Chr(34) & ", " & Chr(34) & _
                          HelpFile & Chr(34) & ", " & Context & ")"
        End If
        FormattedMsgBox = Eval(strMsg)
    End Function
  5. Save the module by using the default name that appears in the Module Name box.
  6. When you want to use the special formatting provided by the at sign, call the FormattedMsgBox function instead of the built-in MsgBox function. For example:
    Sub TestMsgBox()
        Dim lngResult As Long
        lngResult = FormattedMsgBox("Extremely Important@This is an invalid operation.@Refer to online help.", _
            vbCritical + vbOkOnly, "Microsoft Access")
    End Sub

More information

In earlier versions of Microsoft Access, you can use the at sign to format portions of the message text in a MsgBox function. When you use two at signs in the text of the MsgBox function, the text delimited by the at sign is separated into three paragraphs in the Message Box, with the first paragraph in bold text.

This functionality is provided by the Visual Basic for Applications library (Vba332.dll) in Microsoft Access 97. With the integration of the Microsoft Visual Basic Editor, Microsoft Access 2000 no longer implements Vba332.dll.

Steps to Reproduce Behavior

  1. Start Microsoft Access.
  2. Open the sample database Northwind.mdb.
  3. Create a new module.
  4. Add the following code to the module:
    Option Compare Database
    Option Explicit
    Sub FormatMessage()
        Dim strMsgText As String
        strMsgText = "Extremely Important@This is an invalid operation.@" & _
                     "Refer to online help."
        MsgBox strMsgText
    End Sub
  5. Run this procedure in the Immediate window.
Note that the message contains the literal string "Extremely Important@This is an invalid operation.@Refer to online help." In Microsoft Access 95 and 97, this message is formatted into three separate paragraphs with the text "Extremely Important" in bold, similar to the following:
Extremely Important

This is an invalid operation.

Refer to online help.

Applies to
  • Microsoft Access 2000 Standard Edition
kbnosurvey kbarchive kbprb KB242889
Additional support options
Ask The Microsoft Small Business Support Community
Contact Microsoft Small Business Support
Find Microsoft Small Business Support Certified Partner
Find a Microsoft Store For In-Person Small Business Support