And another...
The code below allows you to use the @ symbol just like you could in the
good ol' days of Acc97.
Add this to a code module, then just use FormattedMsg where you would
normally use Msgbox. In your prompt type:
[TitleText]@[explanation]@[Steps to resolve]
e.g.
"Cannot Add New Record@A Record with matching key details already
exists@Please modify the key details or press Esc twice to clear the record"
The title comes out in bold. A gap is left between the title and the
explanation and the steps. Your prompt must contain two @ symbols even if
you are not using one of the three sections.
AFAIK this is the only way to get the first line(s) of a message box in bold
since Acc97. I can't remember where I got this from now, but I use it all
the time.
Public Function FormattedMsgBox(Prompt As String, _
Optional Buttons As Long = vbOKOnly, _
Optional Title As String = "Microsoft Access", _
Optional HelpFile As Variant, _
Optional Context As Variant) As Long
'This code produces a formatted error message box.
'The @ character should be used at the end of the title text and the
description text.
'There must be two @ characters even if there is no description text
'The normal message box function in Access 97 supports use of the @
character to create
' formatted message boxes, but subsequant versions do not. Use this method
even if you
' are developing for Access 97 to prevent problems when moving to later
versions of Acess.
Dim strMsg As String
If IsMissing(HelpFile) Or IsMissing(Context) Then
strMsg = "MsgBox(" & Chr(34) & Prompt & Chr(34) & ", " & Buttons & _
", " & Chr(34) & Title & Chr(34) & ")"
Else
strMsg = "MsgBox(" & Chr(34) & Prompt & Chr(34) & ", " & Buttons & _
", " & Chr(34) & Title & Chr(34) & ", " & Chr(34) & _
HelpFile & Chr(34) & ", " & Context & ")"
End If
FormattedMsgBox = Eval(strMsg)
End Function
el zorro said:
Is there a way to force a new line in MsgBox text?
I'm adding information to the Err.Description message. I
want my text to come first, then the canned
Err.Description text to follow, starting on a new line.
The VBA code I'm using in the On Error subroutine looks
like this:
MsgBox "My instructions to the user " & Err.Description
I want the Error Description to start on a new line. Hey,
and if I could italicize it, that would be cool too, but
I don;t want to over-reach here... any ideas? THanks!