Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Newbury, Berkshire, England
    Posts
    712
    Thanks
    0
    Thanked 0 Times in 0 Posts

    MsgBox with paragraphs

    I found this example in
    Attached Images Attached Images

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: MsgBox with paragraphs

    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?
    Charlotte

  3. #3
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Newbury, Berkshire, England
    Posts
    712
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: MsgBox with paragraphs

    Dear Steve,

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

  4. #4
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Newbury, Berkshire, England
    Posts
    712
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: MsgBox with paragraphs

    Thank you both for your contributions.

    And Steve, it works fine now. I

  5. #5
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Newbury, Berkshire, England
    Posts
    712
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: MsgBox with paragraphs

    I

  6. #6
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: MsgBox with paragraphs

    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.
    Charlotte

  7. #7
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Newbury, Berkshire, England
    Posts
    712
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: MsgBox with paragraphs

    Thanks Charlotte.

  8. #8
    4 Star Lounger SteveH's Avatar
    Join Date
    Jan 2001
    Location
    Chelsea, Gtr London, United Kingdom
    Posts
    587
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Creating a Formatted MsgBox in Access 2000

    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 <A target="_blank" HREF=http://www.mvps.org/access/bugs/bugs0035.htm>http://www.mvps.org/access/bugs/bugs0035.htm</A> regarding this.
    I could not get it to work so I produced the following which does:
    <pre>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
    </pre>


    The code <pre> 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")</pre>

    produces the attached formatted Message box.

    You can create blank lines by passing in an empty string as one of the Prompt arguments.
    HTH
    Attached Images Attached Images
    Steve H
    IT Lecturer/Access Developer
    O2K SR3/O2010; Win7Pro

  9. #9
    4 Star Lounger SteveH's Avatar
    Join Date
    Jan 2001
    Location
    Chelsea, Gtr London, United Kingdom
    Posts
    587
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: MsgBox with paragraphs

    Hi Rupert,
    Just Dim Msg at the start of your procedure should do it.
    <pre>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
    </pre>

    HTH
    Steve H
    IT Lecturer/Access Developer
    O2K SR3/O2010; Win7Pro

  10. #10
    New Lounger
    Join Date
    Jan 2001
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: MsgBox with paragraphs

    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

  11. #11
    melhado
    Guest

    Re: MsgBox with paragraphs

    Maybe someone should let Microsoft know it has been removed .. from the Access 2000 VBE Help file for the MsgBox function example:

    MsgBox Function Example

    The following example uses the MsgBox function to create a formatted error message in Microsoft Access. <font color=red>Note the use of the at sign (@) to denote the different sections of the string.</font color=red>

    Sub CustomMessage()
    Dim strMsg As String, strInput As String

    ' Initialize string.
    strMsg = "Number outside range.@You entered "
    & "a number that is less than 1 or greater "
    & "than 10.@Press OK to enter the number "
    & "again."
    ' Prompt user for input.
    strInput = InputBox("Enter a number between 1 "
    & "and 10.")

    Just an FYI

    'dave

  12. #12
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: MsgBox with paragraphs

    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?
    Charlotte

  13. #13
    melhado
    Guest

    Re: MsgBox with paragraphs

    No Eval function .. here it is straight from the help file's MsgBox function example:

    MsgBox Function Example

    The following example uses the MsgBox function to create a formatted error message in Microsoft Access. Note the use of the at sign (@) to denote the different sections of the string.

    <pre>Sub CustomMessage()
    Dim strMsg As String, strInput As String

    <font color=448800>' Initialize string.</font color=448800>
    strMsg = "Number outside range.@You entered "
    & "a number that is less than 1 or greater "
    & "than 10.@Press OK to enter the number "
    & "again."
    <font color=448800> ' Prompt user for input.</font color=448800>
    strInput = InputBox("Enter a number between 1 "
    & "and 10.")
    <font color=448800> ' Determine if user chose "Cancel".</font color=448800>
    If strInput <> "" Then
    <font color=448800>' Test value of user input.</font color=448800>
    Do While strInput < 0 Or strInput > 10
    If MsgBox(strMsg, vbOKCancel, "Error!") = _
    vbOK Then
    strInput = InputBox("Enter a number between 1 and 10.")
    Else
    Exit Sub
    End If
    Loop
    <font color=448800>' Display user's correct input.</font color=448800>
    MsgBox "You entered the number " & strInput & "."
    Else
    Exit Sub
    End If
    End Sub
    </pre>


  14. #14
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: MsgBox with paragraphs

    Well, I guess not even Microsoft can use the HTML help properly. <img src=/S/shrug.gif border=0 alt=shrug width=39 height=15> <img src=/S/rofl.gif border=0 alt=rofl width=15 height=15>
    Charlotte

  15. #15
    melhado
    Guest

    Re: MsgBox with paragraphs

    next version <img src=/S/evilgrin.gif border=0 alt=evilgrin width=15 height=15>

    'dave

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •