none
Am I doing something wrong here? While writing code that is NOT in production use YET. I wrote a few msgboxes for error handling with a more user friendly msg with help button to Microsoft help based on the “F1” for more help. My msg to user did NOT show RRS feed

  • Question

  • It seems if I want to have a "TITLE' that indicates where the error occurred, or extra buttons,  I must set error trapping level to "Break On Unhandled Errors.  

    and if I want

    to be able to go to the Debug / Compile Project section (When I have an Error)  after looking at the msg.

    I can have one or the other.

    Am I overlooking something? 


    Mark J

    Wednesday, February 1, 2017 10:03 AM

Answers

  • Hi Mark,

    After you dismiss the message box, code execution should continue. So, if you want the user to go to debug mode, then just add a Stop (breakpoint) right after the MsgBox line.

    Hope it helps...

    • Marked as answer by PuzzledByWord Friday, February 3, 2017 1:11 PM
    Wednesday, February 1, 2017 4:39 PM
  • Hi,

    What code are you using now?

    If you want to go to debug mode, you could use Stop Statement or Assert Method

    Dim rsp As Integer
    rsp = MsgBox("Test")
    Stop
    'or use 
    'Debug.Assert rsp <> 1

    Regards,

    Celeste


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by PuzzledByWord Friday, February 3, 2017 1:08 PM
    Thursday, February 2, 2017 3:29 AM
    Moderator

All replies

  • Hi Mark,

    After you dismiss the message box, code execution should continue. So, if you want the user to go to debug mode, then just add a Stop (breakpoint) right after the MsgBox line.

    Hope it helps...

    • Marked as answer by PuzzledByWord Friday, February 3, 2017 1:11 PM
    Wednesday, February 1, 2017 4:39 PM
  • Hi,

    What code are you using now?

    If you want to go to debug mode, you could use Stop Statement or Assert Method

    Dim rsp As Integer
    rsp = MsgBox("Test")
    Stop
    'or use 
    'Debug.Assert rsp <> 1

    Regards,

    Celeste


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by PuzzledByWord Friday, February 3, 2017 1:08 PM
    Thursday, February 2, 2017 3:29 AM
    Moderator
  • "Break on unhandled errors" is a good default value. Years go by that I don't change it.

    > I can have one or the other
    I don't understand what you mean.

    Typically I write code for end users, not for me as a developer. The exception is debug.print and debug.assert which I use a lot to show me what's going on, without taking the focus and interrupting the flow of the application as MsgBox would.

    When an error occurs, I use Ctrl+Break to break into the code so I can see where it happened. If you are new to debugging maybe my YouTube videos will help: https://www.youtube.com/results?search_query=mvp+hour+debugging


    -Tom. Microsoft Access MVP

    Thursday, February 2, 2017 4:44 AM
  • Tom,

    I did look at your youtube on debugging.

    You mentioned   using Ctrl + Break to break into code.

    I found the control key. I did not find any marked break.

    tried to use a send keys  like this  sendkeys "^{BREAK}"  based on what I read in MSDN ref site that also should have worked. also tried with "+" after  "  ^  " didn't seem to work either.

    not sure IF or WHERE I goofed on that sendKey of control+ break

    any ideas?

    Mark J


    Mark J

    Friday, February 3, 2017 12:57 PM
  • Celeste,

    Works perfect, eveytime, no matter what I set the

    Application.SetOption "error trapping" level at.

    Thanks again,

    Mark J.


    Mark J

    Friday, February 3, 2017 1:13 PM
  • .theDBguy,

    Thanks, it works great.

    Mark J


    Mark J

    Friday, February 3, 2017 1:14 PM
  • Not all keyboards have it. On a standard full size kbd it is often combined with the Pause button. Notably it is missing from Surface Pro, which makes it less than ideal for development.

    I am not aware of a SendKeys replacement. I think that would not work in the general sense since Ctrl+Break sends a low level signal to the keyboard driver which then interrupts the CPU and turns control to the debugger. If for example you are looking at a MsgBox, the keystroke would work but SendKeys would not because the UI thread is blocked at MsgBox.

    Try it with a full size keyboard.


    -Tom. Microsoft Access MVP

    Friday, February 3, 2017 2:28 PM
  • .theDBguy,

    Thanks, it works great.

    Mark J


    Mark J

    Hi Mark,

    You're welcome. We're all happy to assist. Good luck with your project.

    Friday, February 3, 2017 3:27 PM