XML RSS
What is this?
Add to My Yahoo!
Add to My MSN
Add to Google

Home
Whats New!
Need a database?
Tips via email
Learn VBA
Questions Answered
Access Tips Index


Forcing a New Line in a Message Box

I know there are other ways to do this, but the one I use consistently with no problems, is by using the Microsoft Access constant known as ‘vbCrLf’. For example, if you have written code to create a message box such as:

MsgBox “The record has now been Saved. The database will now close”

will display in a message box as per below, with just the OK button.

The record has now been Saved. The database will now close.

You may wish, though, to have the second sentence below the first sentence. To do this you would write the code for the message box as:

MsgBox “The record has now been Saved” & vbCrLf & vbCrLf & “The database will now close”.

The two vbCrLf forces two rows in the message box to display the message as:

The record has now been Saved.

The database will now close.

This helps to make your message box easier to read for the user.

You can also use this constant in other instances, for example in setting out text to send in e-mail messages via VBA code.

 

Do you like this tip? Subscribe to my weekly Newsletter to receive tips weekly via email. Click Here to subscribe.

footer for Microsoft Access page