Have you ever wondered how Microsoft Access displays those Custom Message Boxes with the first line in BOLD, and the second and/or second and third lines in Normal Font Weight? The answer lies in the unique ability to break up your Message Text into either two or three Paragraphs using the "@" symbol, then evaluating the entire expression using the Eval() Function.
The "@" symbol inserted into your Message Text will break the Message into Paragraphs, with the Text before the first "@" shown in BOLD. Subsequent Paragraphs (you are limited to three) must be followed by the "@" symbol. If you only want to break for two Paragraphs, you must use two "@" symbols at the end of the second Paragraph. Simply download the Attachment to actually see how this is accomplished. The Attached Code can also be used as a Template for your future 'Spruced Up' Message Boxes!
Special Considerations:
[CODE=vb]
'Code for 2 Paragraphs with OK, Cancel Buttons and an Information Icon, Default Button = 1 [OK]
'(notice the double "@@")
'vbOKCancel = 1
'vbInformation = 64
'TOTAL Constant Value = 65
If Eval("Msgbox('P aragraph 1/Line 1 - this Line will be in BOLD!@Paragraph 2/Line 2 - Click ""OK"" " & _
"to confirm your Delete or ""Cancel"" to UNDO your deletion.@@',65 , 'Message Box Title')") = vbOK Then
MsgBox "You chose OK!"
Else
MsgBox "You Canceled the previous Operation!"
End If
'Code for 3 Paragraphs with Abort, Retry, Ignore Buttons and an Exclamation Icon
'Default Button = 2 [Retry], (each Paragraph separated by "@")
'vbAbortRetryIg nore = 2
'vbExclamation = 48
'vbDefaultButto n2 = 256
'TOTAL Constant Value = 306
Select Case Eval("Msgbox('P aragraph 1/Line 1 - this Line will be in BOLD!@Paragraph 2/Line 2 - Normal Text.@" & _
"Paragraph 3/Line 3 - Normal Text.@',306, " & _
"'Message Box Title')")
Case vbAbort
MsgBox "You Aborted the previous Operation!"
Case vbRetry
MsgBox "Way to go! Let's give it another try!"
Case vbIgnore
MsgBox "You chose to Ignore the previous Operation!"
End Select[/CODE]
The "@" symbol inserted into your Message Text will break the Message into Paragraphs, with the Text before the first "@" shown in BOLD. Subsequent Paragraphs (you are limited to three) must be followed by the "@" symbol. If you only want to break for two Paragraphs, you must use two "@" symbols at the end of the second Paragraph. Simply download the Attachment to actually see how this is accomplished. The Attached Code can also be used as a Template for your future 'Spruced Up' Message Boxes!
Special Considerations:
- You cannot use Variables in your Message Boxes with this Method.
- You cannot use the VB Intrinsic Constants such as vbOKCancel, these Constants must be given as specific numbers which you can readily reference in the Help Files or Object Browser.
[CODE=vb]
'Code for 2 Paragraphs with OK, Cancel Buttons and an Information Icon, Default Button = 1 [OK]
'(notice the double "@@")
'vbOKCancel = 1
'vbInformation = 64
'TOTAL Constant Value = 65
If Eval("Msgbox('P aragraph 1/Line 1 - this Line will be in BOLD!@Paragraph 2/Line 2 - Click ""OK"" " & _
"to confirm your Delete or ""Cancel"" to UNDO your deletion.@@',65 , 'Message Box Title')") = vbOK Then
MsgBox "You chose OK!"
Else
MsgBox "You Canceled the previous Operation!"
End If
'Code for 3 Paragraphs with Abort, Retry, Ignore Buttons and an Exclamation Icon
'Default Button = 2 [Retry], (each Paragraph separated by "@")
'vbAbortRetryIg nore = 2
'vbExclamation = 48
'vbDefaultButto n2 = 256
'TOTAL Constant Value = 306
Select Case Eval("Msgbox('P aragraph 1/Line 1 - this Line will be in BOLD!@Paragraph 2/Line 2 - Normal Text.@" & _
"Paragraph 3/Line 3 - Normal Text.@',306, " & _
"'Message Box Title')")
Case vbAbort
MsgBox "You Aborted the previous Operation!"
Case vbRetry
MsgBox "Way to go! Let's give it another try!"
Case vbIgnore
MsgBox "You chose to Ignore the previous Operation!"
End Select[/CODE]
Comment