+ Reply to Thread
Results 1 to 23 of 23

"Can't enter break mode at this time" (Issues with adding controls at runtime)

  1. #1
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Angry "Can't enter break mode at this time" (Issues with adding controls at runtime)

    Hello All,

    I have recently been working on a form which has its buttons added at runtime. It works well except for one problem. Suppose I am debugging one of the procedures that are called from the buttons. I insert a break point in the VBA editor. When the code reaches the breakpoint, VBA displays a message "Can't enter break mode at this time"

    This is frustrating and I want to find a way around this (so that breakpoints still work).

    I have tried googling the problem - the problem appears to be well known (although most of the discussions revolve around adding controls to a worksheet at runtime) but I can't find any definite solution.

    Any help would be appreciated.
    *******************************************************

    HELP WANTED! (Links to Forum threads)
    Trying to create reusable code for Custom Events at Workbook (not Application) level

    *******************************************************

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: "Can't enter break mode at this time" (Issues with adding controls at runtime)

    Is the code for the buttons also added at runtime?
    If posting code please use code tags, see here.

  3. #3
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: "Can't enter break mode at this time" (Issues with adding controls at runtime)

    Yes. Form, controls & code for controls are added at runtime.

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: "Can't enter break mode at this time" (Issues with adding controls at runtime)

    What code is it you are trying to debug?

  5. #5
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: "Can't enter break mode at this time" (Issues with adding controls at runtime)

    Any code that is called from the controls added at runtime.

    (The content of the called code doesn't matter because, from what I have found by googling, the problem is caused by adding controls at runtime).

  6. #6
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: "Can't enter break mode at this time" (Issues with adding controls at runtime)

    Are you adding them normally, or with some nasty hacky code that writes code for each button?

  7. #7
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: "Can't enter break mode at this time" (Issues with adding controls at runtime)

    Quote Originally Posted by Kyle123 View Post
    Are you adding them normally, or with some nasty hacky code that writes code for each button?
    What's the difference? (I'm still a novice)

    Probably the latter I guess. The adding buttons to a temp form has this "can't enter break mode" issue.

  8. #8
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: "Can't enter break mode at this time" (Issues with adding controls at runtime)

    What do you mean by 'temp' form?

    If it's temporary form why is it temporary and what's its purpose?

  9. #9
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: "Can't enter break mode at this time" (Issues with adding controls at runtime)

    I suspect the IDE doesn't like you trying to debug at the same time you're trying to automate it. If you add the controls in the normal way, this issue won't occur as per the other thread

  10. #10
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: "Can't enter break mode at this time" (Issues with adding controls at runtime)

    If your code performs an action that would result in a state loss you may not step through it - that is the same issue with adding controls to worksheets.

  11. #11
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: "Can't enter break mode at this time" (Issues with adding controls at runtime)

    Quote Originally Posted by Norie View Post
    What do you mean by 'temp' form?
    I was using shorthand in my reply to Kyle to refer to another one of my threads here. (One that you and Kyle have both helped me on)
    http://www.excelforum.com/excel-prog...t-runtime.html

  12. #12
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: "Can't enter break mode at this time" (Issues with adding controls at runtime)

    Quote Originally Posted by Izandol View Post
    If your code performs an action that would result in a state loss you may not step through it - that is the same issue with adding controls to worksheets.
    But I receive this error message on code that doesn't result in a state loss?

  13. #13
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: "Can't enter break mode at this time" (Issues with adding controls at runtime)

    What error message?

  14. #14
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: "Can't enter break mode at this time" (Issues with adding controls at runtime)

    I've found a possible solution http://support.microsoft.com/kb/q155051

    But how do I programmatically add a non-ActiveX control to the form instead of an ActiveX control?

  15. #15
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: "Can't enter break mode at this time" (Issues with adding controls at runtime)

    As far as I know only ActiveX controls can be added to userforms.

  16. #16
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: "Can't enter break mode at this time" (Issues with adding controls at runtime)

    Quote Originally Posted by mc84excel View Post
    But I receive this error message on code that doesn't result in a state loss?
    If you would like a complete answer you must frame a complete question: what is the code?

  17. #17
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: "Can't enter break mode at this time" (Issues with adding controls at runtime)

    Quote Originally Posted by Norie View Post
    As far as I know only ActiveX controls can be added to userforms.
    That's what I thought but I was afraid to say so (I'm still a novice)

    What on earth does MS mean then? (in the MS Support link)

  18. #18
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: "Can't enter break mode at this time" (Issues with adding controls at runtime)

    The causes of the problem are described as,

    •You programmatically add an ActiveX control to a worksheet.

    -and-

    •You step through the macro.

    no userform mentioned.

  19. #19
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: "Can't enter break mode at this time" (Issues with adding controls at runtime)

    Quote Originally Posted by Izandol View Post
    If you would like a complete answer you must frame a complete question: what is the code?
    Sorry I don't have time at the moment to create generic demo code to recreate this issue.

    Otherwise if an existing workbook is fine, see thread http://www.excelforum.com/excel-prog...t-runtime.html and "GoTo" * post #10 and dl the attachment. From memory that has this "can't enter break mode" issue.

    * (injoke between me and Izandol)

  20. #20
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: "Can't enter break mode at this time" (Issues with adding controls at runtime)

    Quote Originally Posted by Norie View Post
    The causes of the problem are described as,

    •You programmatically add an ActiveX control to a worksheet.

    -and-

    •You step through the macro.

    no userform mentioned.
    Yes I know But the issue described is very similar to what I'm getting. The difference is the cause. I incur the issue when I programatically add ActiveX controls to a UserForm and then run the code with breakpoints set.

  21. #21
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: "Can't enter break mode at this time" (Issues with adding controls at runtime)

    Quote Originally Posted by mc84excel View Post
    The difference is the cause.
    You've hit the nail on the head there - this isn't the same issue...

    Just add your controls properly, stop hacking the IDE and live in bliss

  22. #22
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: "Can't enter break mode at this time" (Issues with adding controls at runtime)

    Your workbook in the previous thread did cause state loss because you were altering the actual VBProject by using the Designer.

  23. #23
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: "Can't enter break mode at this time" (Issues with adding controls at runtime)

    I'm marking this thread as solved.

    Don't add controls to forms at run-time.

    If you really need to, there is an alternative method of adding controls (thanks to Kyle123) - See http://www.excelforum.com/excel-prog...t-runtime.html

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. "Can't enter break mode at this time" error
    By jp001 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-11-2009, 09:19 AM
  2. [SOLVED] "Can't enter break mode at this time"
    By Paul T. in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-21-2006, 07:00 PM
  3. Make "Edit" mode default, rather than "Enter"?
    By Greg Boettcher in forum Excel General
    Replies: 1
    Last Post: 07-26-2006, 08:50 PM
  4. [SOLVED] Can't enter break mode at this time
    By CWillis in forum Excel General
    Replies: 2
    Last Post: 06-01-2006, 02:45 PM
  5. "Can't Enter Break Mode"?
    By CWillis in forum Excel General
    Replies: 2
    Last Post: 05-31-2006, 04:20 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1