Results 1 to 7 of 7
  1. #1
    Lounger
    Join Date
    Sep 2001
    Location
    NSW, Australia
    Posts
    30
    Thanks
    0
    Thanked 0 Times in 0 Posts

    MsgBox function not working (AccessXP SP1)

    Did Microsoft in their wisdom decide to drop the MsgBox function in Microsoft Access XP where you could create a formatted error message similar to built-in error messages displayed by Microsoft Access by separating the sections with the at sign (@). All message boxes using @ sign have stopped working properly since I started converting our Access 97 database to Access XP.

    For example, the following example works fine in Access97 but not AccessXP as intended.

    strMsg = "This could take a long time!" _
    & "@Depending on the number of records required to be processed " _
    & "this function could take anywhere between 30 seconds and 60 minutes. " _
    & vbCrLf & vbCrLf & "Press OK button now to start the process or Cancel button to exit." _
    & "@WARNING: Do NOT press Cancel or Exit buttons while the process is in progress " _
    & "becuse this could result in lost emails."
    beep
    intDoIt = MsgBox(strMsg, vbQuestion + vbOKCancel + vbDefaultButton1, "Are you sure?")

    See attached word file for screen shots.
    Attached Files Attached Files

  2. #2
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,623
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: MsgBox function not working (AccessXP SP1)

    Actually, this capability was changed in Office 2000 - it's a VBA problem with version 6. This Microsoft Knowledge Base article gives the details. Sorry.
    Wendell

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

    Re: MsgBox function not working (AccessXP SP1)

    Actually, that change came in Access 2000, not XP. IN A2k and later, you have to use the Eval() function like this:

    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')")
    Charlotte

  4. #4
    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 function not working (AccessXP SP1)

    See <!post=this post and thread,35509>this post and thread<!/post> for a workaround.
    Steve H
    IT Lecturer/Access Developer
    O2K SR3/O2010; Win7Pro

  5. #5
    Lounger
    Join Date
    Sep 2001
    Location
    NSW, Australia
    Posts
    30
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: MsgBox function not working (AccessXP SP1)

    Excellent, just what I wanted.

    Thanks Charlotte

    Must buy a drink one day to thank you for all the help you gave me lately. <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

    Steve thanks to you as well.

  6. #6
    Lounger
    Join Date
    Sep 2001
    Location
    NSW, Australia
    Posts
    30
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: MsgBox function not working (AccessXP SP1)

    I was too quick with my previous reply.

    Eval function works fine on a one line message; however we will not be able to use it.

    If I try something like this (one line)

    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')")

    it works fine, however if I try something like this (multiple line for easy of maintenance)

    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')")


    it does not work. It also does not like any line continuation or any kind of variable.

    This also does not work

    Eval("MsgBox('You have just deleted the current record.@ Click ""OK"" to confirm your delete or ""Cancel"" to undo your deletion.@@', vbOKCancel, 'Test Message Box')")
    it does not recognise vbOKCancel constant (refer to attached word file).

    if try

    Dim strMsg as String

    strMsg = " You have just deleted the current record.@ Click ""OK"" to confirm your delete or ""Cancel"" to undo your deletion.@@"


    and then try

    Eval("MsgBox(strMsg, 1, 'Test Message Box')")

    I still get an error Eval does not seem to recognise strMsg as a valid variable even when declared above the Eval statement (refer to attached word file).

    Back to the drawing board
    Attached Files Attached Files

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

    Re: MsgBox function not working (AccessXP SP1)

    No, it won't recognize system constants or user defined variables inside the string. If you want to use system constants, you will have to pass in the actual value, not the name of the constant.. As for line continuations, it wasn't the line continuations it was objecting to, it was the quotes. This works:

    <pre>Public Function TestEval()
    Dim strMsg As String

    strMsg = "MsgBox('You have just deleted the current record.@ " _
    & "Click ""OK"" to confirm your delete or ""Cancel"" to undo " _
    & "your deletion.@@',1, 'Test Message Box')"

    Call Eval(strMsg)

    End Function</pre>

    Charlotte

Posting Permissions

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