Bold Text on Message Box

6

'69 Camaro

Hi, Charles.
I would like to display Bolded strings on a message box.

If you have Access 97, that's easy because the Access MsgBox( ) function is
called, which allows bold text along with normal text. In subsequent
versions of Access the VBA MsgBox( ) function is called, which doesn't allow
this functionality. However, the Access MsgBox( ) function can be forced to
be used instead of the VBA MsgBox( ) function by using the Eval( ) function.
The syntax is a little tricky, though. For example (watch out for word wrap):

' * * * * Start code * * * *

Dim sMsg As String
Dim sTitle As String

sMsg = "This is the 1st line in bold type.@This is the 2nd line.@This is
the 3rd line."
sTitle = "This Is The Title"

Eval ("MsgBox(""" & sMsg & """, " & vbOKOnly + vbExclamation & _
", """ & sTitle & """)")

' * * * * End code * * * *

Only the first line will be in bold type. The second and third lines will
not. If you'd like multiple lines in bold type, then add the vbCrLf constant
between these lines. For example:

sMsg = "This is the 1st line in bold type." & vbCrLf & _
"This is the 2nd line in bold type.@This is the 3rd line.@This is
the 4th line."

If you only want bold type and not normal type, then the following would work:

sMsg = "This is the 1st line in bold type." & vbCrLf & _
"This is the 2nd line in bold type.@@ "

There must be at least one character (in this case, a space) after the
second @ sign in order for the text before the @@ to be in bold type.

HTH.

Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address, so that a message
will be forwarded to me.)
Beware to those who use munged addresses: known newsgroup E-mail harvesters
for spammers are (e-mail address removed) and (e-mail address removed)

- - -
When you see correct answers to your question posted in Microsoft's Online
Community, please sign in to the Community and mark these posts as "Answers,"
so that all may benefit by filtering on "Answered questions" and quickly
finding the right answers to similar questions. Remember that the first and
best answers are often given to those who have a history of rewarding the
contributors who have taken the time to answer questions correctly.
 
I

Irshad Alam

Thanks for your advise. It gave me a good knowledge about the message box.

One additional question to this, Is it possible to change the color of any
of the line, like If I want to keep the first line Font Color Red and bold
Second line Blue font and Bold
Third line Black font and normal font.

If it is possible, please advise. It will be give more professional looks to
message box.

Regards.

Irshad
 
6

'69 Camaro

Hi, Irshad.
One additional question to this, Is it possible to change the color of any
of the line, like If I want to keep the first line Font Color Red and bold
Second line Blue font and Bold
Third line Black font and normal font.

The message box font, font color and font size are all Windows system
settings, so all lines of text would use these same settings. If you would
like to customize the message box further with different colors and such for
each line of text, then you will need to create a custom dialog form and open
that from VBA code instead of the Window's system message box.

HTH.

Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address, so that a message
will be forwarded to me.)
Beware to those who use munged addresses: known newsgroup E-mail harvesters
for spammers are (e-mail address removed) and (e-mail address removed)

- - -
When you see correct answers to your question posted in Microsoft's Online
Community, please sign in to the Community and mark these posts as "Answers,"
so that all may benefit by filtering on "Answered questions" and quickly
finding the right answers to similar questions. Remember that the first and
best answers are often given to those who have a history of rewarding the
contributors who have taken the time to answer questions correctly.
 
C

Charles Tam

Thanks for your reply. I'm using Access 97.
Hi, Charles.


If you have Access 97, that's easy because the Access MsgBox( ) function is
called, which allows bold text along with normal text. In subsequent
versions of Access the VBA MsgBox( ) function is called, which doesn't allow
this functionality. However, the Access MsgBox( ) function can be forced to
be used instead of the VBA MsgBox( ) function by using the Eval( ) function.
The syntax is a little tricky, though. For example (watch out for word wrap):

' * * * * Start code * * * *

Dim sMsg As String
Dim sTitle As String

sMsg = "This is the 1st line in bold type.@This is the 2nd line.@This is
the 3rd line."
sTitle = "This Is The Title"

Eval ("MsgBox(""" & sMsg & """, " & vbOKOnly + vbExclamation & _
", """ & sTitle & """)")

' * * * * End code * * * *

Only the first line will be in bold type. The second and third lines will
not. If you'd like multiple lines in bold type, then add the vbCrLf constant
between these lines. For example:

sMsg = "This is the 1st line in bold type." & vbCrLf & _
"This is the 2nd line in bold type.@This is the 3rd line.@This is
the 4th line."

If you only want bold type and not normal type, then the following would work:

sMsg = "This is the 1st line in bold type." & vbCrLf & _
"This is the 2nd line in bold type.@@ "

There must be at least one character (in this case, a space) after the
second @ sign in order for the text before the @@ to be in bold type.

HTH.

Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address, so that a message
will be forwarded to me.)
Beware to those who use munged addresses: known newsgroup E-mail harvesters
for spammers are (e-mail address removed) and (e-mail address removed)

- - -
When you see correct answers to your question posted in Microsoft's Online
Community, please sign in to the Community and mark these posts as "Answers,"
so that all may benefit by filtering on "Answered questions" and quickly
finding the right answers to similar questions. Remember that the first and
best answers are often given to those who have a history of rewarding the
contributors who have taken the time to answer questions correctly.
 
6

'69 Camaro

Hi, Charles.
On the same line, how do I bold a word or two but not the entire line?

Unfortunately, only the line of text in a message box can be formatted with
bold text, not individual words in that line of text. If you need something
more customized, then you'll need to create your own custom dialog form and
use that instead of the Windows system message box. If this is the case,
then you may be interested in Stephen Lebans's Rich Text control, which also
works with Access 97, on the following Web page:

http://www.lebans.com/richtext.htm

HTH.

Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address, so that a message
will be forwarded to me.)
Beware to those who use munged addresses: known newsgroup E-mail harvesters
for spammers are (e-mail address removed) and (e-mail address removed)
 
D

Dorci

Jeff,
That MsgBox Creator is the bomb!!! And it easily converts to Access 2000
(which allows you to drag-n-drop the objects directly into your own
database). Thanks for the tip.
 

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