Microsoft Knowledge Base Email Alertz

If you want to force a new line in a message box, you can include either: The Visual Basic for Applications constant for a carriage return and line feed, vbCrLf . -or- The character codes for a carriage return and line feed,

Search KbAlertz

Advanced Search

Receive Microsoft Knowledge Base articles by E-Mail?

Every night we scan the Microsoft Knowledge Base. If technologies you're interested in are updated, we'll send you an e-mail. You only get one e-mail a day, and only when new articles are added.

Click here to create a
FREE account
Already have an account?
[Click here to Login]











Microsoft Knowledge Base Article

This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks

Article ID: 281670 - Last Review: March 28, 2007 - Revision: 7.1

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

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  (http://kbalertz.com/Feedback.aspx?kbNumber=209791/EN-US/ ) .

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.

APPLIES TO
  • Microsoft Office Access 2007
  • Microsoft Office Access 2003
  • Microsoft Access 2002 Standard Edition
Keywords: 
kbprogramming kbhowto KB281670
       

Community Feedback System

Very often, it takes hours to solve a problem. Very often, you've looked high and low, and have tried a lot of solutions. When you finally found it, chances are, it was because someone else helped you. Here's your chance to give back. Use our community feedback tool to let others know what worked for you and what didn't.

Please also understand that the community feedback system is not warranted to be correct, it's simply a system that we've built to let people try and help each other. If something in a feedback response doesn't make sense to you, or you're not comfortable making changes that the feedback talks about (like registry edits), please consult a professional.

Thank you for using kbAlertz.com Feedback System.

-- Scott Cate