Message Box Size Text Wrap

  • Thread starter Thread starter Brook
  • Start date Start date
B

Brook

Does anyone know how to code a Message Box to be a certain
Size and wrap the text within the Text Box.

Thanks,

Brook
 
Brook said:
Does anyone know how to code a Message Box to be a certain
Size and wrap the text within the Text Box.

MsgBox "this is on line 1" & vbCrLf & "this is on line 2"
 
My Message Box is based upon a table lookup, any
suggestion on that? Here is my code:


Private Sub Form_Load()
Dim varNotice As Variant

varNotice = DLookup
("specialnotice", "qrySpecialNoticesQuery")
If Nz(varNotice, "") <> "" Then
MsgBox varNotice, vbCritical, "Special Notice"

End If

End Sub


Thanks,

Brook
 
My Message Box is based upon a table lookup, any
suggestion on that? Here is my code:

Private Sub Form_Load()
Dim varNotice As Variant

varNotice = DLookup
("specialnotice", "qrySpecialNoticesQuery")
If Nz(varNotice, "") <> "" Then
MsgBox varNotice, vbCritical, "Special Notice"

End If

End Sub

Thanks,

Brook

I take it the [SpecialNotice] field contains messages.

You have no control over how wide the message box will be, and you
haven't given any indication of what the actual text will be.

1) If you ALWAYS had a special character in the field (i.e. "\") to
indicate the end of the line, you could use:
MsgBox Left(varNotice,Instr(varNotice,"\")-1) & vbNewLine &
Mid(varNotice,InStr(varNotice,"\")+1), vbCritical, "Special Notice"

2) Better yet, why not just include the new lines directly in the
field when the data is being entered.
Use Ctrl + Enter at the proper place when entering the text (or set
the Enter key Behavior property to New Line in field).

3) If you are looking to actually control the width of the message
box, I would suggest you use an unbound form with a label control
instead.
You can size the label as wide as you wish and the caption text will
break to the next line as needed as long as the label is tall enough.
I would set the label back color style to transparent.
Use
DoCmd.OpenForm "MessageForm", , , , , acDialog,varMessage
To open the form.

Read the OpenArgs in the message form's Load event.
If Not IsNull(Me.OpenArgs) Then
LabelName.Caption = Me.OpenArgs
End If
Add a command button to close the message form and send processing
back to the previous form.
 
Back
Top