How to force a new line in a MsgBox message in Access

Article translations Article translations
Article ID: 281670 - View products that this article applies to.
This article was previously published under Q281670
Moderate: Requires basic macro, coding, and interoperability skills.

This article applies to either a Microsoft Access database (.mdb) file or to a Microsoft Access database (.accdb) file, and to a Microsoft Access project (.adp) file.For a Microsoft Access 2000 version of this article, see 209791.
Expand all | Collapse all

SUMMARY

If you want to force a new line in a message box, you can include one of the following:
  • The Visual Basic for Applications constant for a carriage return and line feed, vbCrLf.
  • The character codes for a carriage return and line feed, Chr(13) & Chr(10).
For example, if you had the following 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 as in either of the following examples:
  • Example Using the Visual Basic for Applications Constant:
    MsgBox "NOTICE:" & vbCrLf & "This is an Important Message!"
    					
  • Example Using the Character Codes:
    MsgBox "NOTICE:" & Chr(13) & Chr(10) & "This is an Important Message!"
    					
You can also use the vbCrLf constant to create multiple lines in a text box on a form or on a data access page.

REFERENCES

For more information about character codes, in the Visual Basic Editor, click Microsoft Visual Basic Help on the Help menu, type Chr function in the Office Assistant or the Answer Wizard, and then click Search to view the topic.

Properties

Article ID: 281670 - Last Review: March 28, 2007 - Revision: 7.1
APPLIES TO
  • Microsoft Office Access 2007
  • Microsoft Office Access 2003
  • Microsoft Access 2002 Standard Edition
Keywords: 
kbprogramming kbhowto KB281670

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com