• MsgBox with paragraphs

    Author
    Topic
    #355500

    I found this example in

    Viewing 2 reply threads
    Author
    Replies
    • #524489

      Sorry, Rupert, but that functionality was removed from VBA 6/Office 2000. Now you have to concatenate a vbCrLf to the string to get the paragraph breaks and there’s no way I know of to make part of the text bold. If you include the @ in a messagebox string, it is interpreted as a literal in this version.

      The continuation character is actually a space + an underscore. If you use it in the middle of a concatenated string, you have to include an ampersand either before the continuation character(s) or after them at the start of the next line. If you use the continuation within a function and between arguments, you don’t need a concatenation character. Does that help?

      • #524590

        In Access 97, you could create a messagebox with paragraph breaks in the text and with a portion of the message in bold by using the @ symbol in the prompt. In Access 2000, the @ is interpreted as a literal part of the string, so you can’t create a formatted messagebox using the built-in function.

        There is a post on http://www.mvps.org/access/bugs/bugs0035.htm regarding this.
        I could not get it to work so I produced the following which does:

        Public Function FormattedMsgBox( _
         Prompt1 As String, Prompt2 As String, Prompt3 As String, _
         Optional Buttons As VbMsgBoxStyle = vbOKOnly, _
         Optional Title As String = vbNullString, _
         Optional HelpFile As Variant, _
         Optional Context As Variant) _
         As VbMsgBoxResult
        On Error Resume Next
            If IsMissing(HelpFile) Or IsMissing(Context) Then
                FormattedMsgBox = Eval("MsgBox(""" & Prompt1 & "@" & _
                Prompt2 & "@" & Prompt3 & """,  " & _
                  Buttons & ", """ & Title & """)")
            Else
                FormattedMsgBox = Eval("MsgBox(""" & Prompt1 & "@" & _
                Prompt2 & "@" & Prompt3 & """,  " & _
                  Buttons & ", """ & Title & """, """ & _
                  HelpFile & """, " & Context & ")")
            End If
        End Function
        

        The code

            Msg = FormattedMsgBox("The authority for the use of " _
                & "this System has been removed or is incorrect", _
                "Check that your computer's system date is " _
                & "correct or seek technical help", _
                "Courses Database cannot be opened", 16, _
                "Courses Database")

        produces the attached formatted Message box.

        You can create blank lines by passing in an empty string as one of the Prompt arguments.
        HTH

        • #524642

          Dear Steve,

          I put the function into a module and tried to use the code:-

          • #524684

            Hi Rupert,
            Just Dim Msg at the start of your procedure should do it.

            Sub TestMessage()
            Dim Msg
                Msg = FormattedMsgBox("The authority for the use of " _
                     & "this System has been removed or is incorrect", _
                     "Check that your computer's system date is correct " _
                     & "or seek technical help", _
                    "Courses Database cannot be opened", 16, "Courses Database")
            End Sub
            

            HTH

            • #524735

              Thank you both for your contributions.

              And Steve, it works fine now. I

            • #524737

              I

            • #524754

              By the X logo, do you mean the critical button? Those icons can be changed by passing the correct vb constants for vbInformation, vbCritical, vbQuestion, etc., added to the constant that defines the buttons.

            • #524762

              Thanks Charlotte.

            • #525256

              Hi Rupert

              Give this a try

              If Eval(“MsgBox(‘You have just deleted the current record.@ Click “”OK”” to confirm your delete or “”Cancel”” to undo your deletion.@@’,1, ‘Test Message Box’)”) = vbOK Then

              ‘Do somthing here
              End If

            • #600066

              I noticed the problem (bug) in Access97 SR2. It works great for returning an email address. If you want the carriage returns, you could try this:

              If Eval(“MsgBox(‘You have just deleted the current record.” & chr(13) & “Click “”OK”” to confirm your delete or “”Cancel”” to undo your deletion.” & chr(13) & chr(13)‘,1, ‘Test Message Box’)”) = vbOK Then

              ‘Do somthing here
              End If

              That format worked for me when getting an email address from a text box and displaying it in the message part of the message box with other text and line breaks.

    • #530936

      You didn’t post the part of the code that would call the msgbox. Did they use the eval function or just post the raw msgbox usage?

    • #531020

      Well, I guess not even Microsoft can use the HTML help properly. shrug rofl

    Viewing 2 reply threads
    Reply To: MsgBox with paragraphs

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: