Manufacturing Information Solutions Forum Index Manufacturing Information Solutions
Your Place for Support and Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Bold text in a message box

 
Post new topic   Reply to topic    Manufacturing Information Solutions Forum Index -> Microsoft Access
View previous topic :: View next topic  
Author Message
BIGmiralli
Frequent Poster


Joined: 17 Apr 2007
Posts: 38
Location: Boston, Massachusetts

PostPosted: Fri Jan 04, 2008 12:58 pm    Post subject: Bold text in a message box Reply with quote

I want to bold a word in a message box, how can I do that?
________
EXTREME VAPORIZER


Last edited by BIGmiralli on Wed Feb 16, 2011 10:40 am; edited 1 time in total
Back to top
View user's profile Send private message
dawn
Master Poster


Joined: 26 Jun 2004
Posts: 311
Location: Mishawaka, IN

PostPosted: Fri Jan 04, 2008 1:09 pm    Post subject: Reply with quote

Developer's since Access 1.x have used the combination of Chr(10) & Chr(13) & Chr(10) to break message boxes into paragraphs. Since Access 95 you could use the intrinsic constants "vbCrlf" to do the same thing.
Both Access 95 and 97 allow you to not only break your message box into paragraphs, but also allow you to bold the first paragraph in the Message Box, just like Access itself does with standard messages. However, creating this functionality in Access 2000 this is a bit more limited and tricky as noted below.
The "@" symbol added to your message text will break the message into paragraphs, with text before the first @ shown in bold. You are limited to three paragraphs with the "@" symbol following each paragraph. If you only want to break for two paragraphs, you must use two @@ symbols at the end of the second paragraph.
The following code shows a formatted message box for Access 95-97:

Code:
If MsgBox("You have just deleted the current record.@ _
     Click ""OK"" to confirm your delete or ""Cancel"" to undo your deletion.@@ ", _
     vbOKCancel, "My AppName") = vbOK Then

         'Do somthing here
End If


In Access 2000, this functionality is not directly available because the VBA environment is now separate from Access. You can however replicate it (with certain limitations) by using the EVAL function as a wrapper around the message box code. So it would look like:

Code:
If Eval("MsgBox('You have just deleted the current record.@ _
     Click ""OK"" to confirm your delete or ""Cancel"" to undo your deletion.@@', _
     1, 'My AppName')") = vbOK Then

         'Do somthing here
End If


Note: You can not use variables in your message boxes using this method and you also can't use VB intrinsic constants such as vbOKCancel, the latter must be given as specific numbers which you can obtain using the object browser.
_________________
Dawn Mitchell
Manufacturing Information Solutions
www.mis-group.com
Back to top
View user's profile Send private message Send e-mail
mistux
Site Admin


Joined: 25 Jun 2004
Posts: 1042
Location: South Bend, Indiana USA

PostPosted: Fri Jan 04, 2008 1:15 pm    Post subject: Reply with quote

Creating the FormattedMsgBox Function

The Eval function forces the Visual Basic for Applications expression service to evaluate the MsgBox function separately from Visual Basic Editor, and therefore it is possible to take advantage of at sign formatting. The following example uses a user-defined function named FormattedMsgBox instead of the MsgBox function.

To create the FormattedMsgBox function, follow these steps:

1. Start Microsoft Access.
2. Open the sample database Northwind.mdb.
3. Create a new module.
4. Add the following procedure to the module:

Code:
Function FormattedMsgBox(Prompt As String, _
                         Optional Buttons As VbMsgBoxStyle = vbOKOnly, _
                         Optional Title As String = "Microsoft Access", _
                         Optional HelpFile As Variant, _
                         Optional Context As Variant) As VbMsgBoxResult
    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


5. Save the module by using the default name that appears in the Module Name box.
6. When you want to use the special formatting provided by the at sign, call the FormattedMsgBox function instead of the built-in MsgBox function.

For example:
Code:
Sub TestMsgBox()
    Dim lngResult As Long
    lngResult = FormattedMsgBox("Extremely Important@This is an invalid operation.@Refer to online help.", _
        vbCritical + vbOkOnly, "Microsoft Access")
End Sub


This article was previously published under Microsoft Knowledgbase Q242889 http://support.microsoft.com/kb/242889
Back to top
View user's profile Send private message Send e-mail
mistux
Site Admin


Joined: 25 Jun 2004
Posts: 1042
Location: South Bend, Indiana USA

PostPosted: Fri Jan 04, 2008 1:18 pm    Post subject: Reply with quote

You could also just crate a small little pop-up form that is "model" that has the info you want on it with the buttons you want.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    Manufacturing Information Solutions Forum Index -> Microsoft Access All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group