How to force a new line in a MsgBox message (281670)



The information in this article applies to:

  • Microsoft Office Access 2003
  • Microsoft Access 2002

This article was previously published under Q281670
Moderate: Requires basic macro, coding, and interoperability skills.

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

For a Microsoft Access 2000 version of this article, see 209791.

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.

Modification Type:MinorLast Reviewed:6/7/2004
Keywords:kbProgramming kbhowto KB281670 kbAudDeveloper