ACC: How to Force a New Line in a MsgBox Message

Last reviewed: April 2, 1997
Article ID: Q90810
The information in this article applies to:
  • Microsoft Access versions 1.0, 1.1, 2.0, 7.0, 97

SUMMARY

Moderate: Requires basic macro, coding, and interoperability skills.

If you want to force a new line in a message box, you can enter the message as a string formula and concatenate a carriage return/line feed, Chr$(13) + Chr$(10), in the message anywhere you want to start a new line.

You can also use this technique to provide multiple lines in a text box on a form.

MORE INFORMATION

For example, if you had the message

   Notice: This is an Important Message!

and, you wanted the message to be displayed as

   Notice:
   This is an Important Message!

you would enter the message as a string expression with the following syntax in either a macro or in code:

 In a Macro
 ----------

  Action
  ------
  MsgBox
  Message: ="Notice:" & Chr(13) & Chr(10) & "This is an Important
  Message!"

  NOTE: You must use the equal sign with the MsgBox action to tell the
  action you are using a String expression as the message argument.

 In Code
 -------

  MsgBox "Notice:" & Chr(13) &Chr(10) & "This is an Important Message!"

  NOTE: When using the MsgBox statement or MsgBox() function in code,
  you do not need the equal sign before the message because this
  statement/function expects a string expression as the message argument.

  NOTE: While this code sample works fine in Microsoft Access 7.0 and 97,
  you can also use the Visual Basic constant vbCrLf in place of Chr(13)
  & Chr(10) in this code sample. The line of code would then read as
  follows:

     MsgBox "Notice:" & vbCrLf & "This is an Important Message!"


Additional query words: multiline
Keywords : kbusage McrArg
Version : 1.0 1.10 2.0 7.0 97
Platform : WINDOWS
Hardware : X86
Issue type : kbhowto


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: April 2, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.