Message Box Size Text Wrap

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
 
R

Rick Brandt

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"
 
B

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
 
F

fredg

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top