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.
-
Open a form
and put a button on it.
-
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
-
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"
|