Access Tips

Back to Hints and Tips Index                                             Back to Main Index

Message Boxes and wrapping text (Intermediate)

To display a message, you can use the MsgBox() function.

Unfortunately, you can not control how Access displays it.

For instance, if your message is long, Access, not you, determines where to wrap it.

You can take back control using the Chr(13) or the Vbcrlf and VbTab functions.

  1. Open a form and put a button on it.

  2. In the OnClick property put:

MsgBox("This message is too long so" & Chr(13) & "we added a Chr(13) function to wrap the text.")

and then click the button.

Access returns a message box displaying two lines of text.

OR

  1. Instead of chr(13) you can also use vbcrlf to generate a hard return and also vbTab to generate tabs.

So you could try the following behind this same button:

Dim Msg as string

msg = "This is a test of the hard returns and tabs:" & vbcrlf & vbcrlf

msg = msg & vbTab & "Here is a tab." & vbcrlf

msg = msg & vbtab & vbtab & "You can use these to shape your message."

msgbox msg, vbinformation+vbOk, "Tab Test"

Drag and drop columns in Access' query design grid (Basic)

If you have ever needed to reorder columns in the query design grid, you may have been frustrated to find Access simply selects adjacent columns when you intend on moving them.

The design grid supports drag-and-drop; you just need to wait a moment after selecting the fields before you attempt to move them. After the brief pause, click and drag the top of the selected columns to move the fields to their new locations.

Back to Hints and Tips Index                                             Back to Main Index