Results 1 to 11 of 11

Thread: Stop Code

  1. #1
    Join Date
    May 2005
    Posts
    1,191

    Unanswered: Stop Code

    I'm in the development stage of a database, and I'm using some large For loops and while loops, my question is this:
    If I accidentally get stuck in an infinite loop, is there a key combo or something (besides ctl+alt+del and end task) that will allow me to stop the code from processing?
    Me.Geek = True

  2. #2
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    Ctrl-Break
    Paul

  3. #3
    Join Date
    May 2005
    Posts
    1,191
    Thanks for that, i new it was something easy like that
    Me.Geek = True

  4. #4
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Yep -that is nice.

    I sometimes put in a debug.print of the value I am testing in the loop and a check of the number of loops. If number of loops > some figure that can only occur if Things Go Wrong then exit loop. This code is then removed once I have sorted out my logic. The print to immediate window can help debug the code. Of course, this is only really worth the effort if you have something complex going on and you are struggling to pin down the problem and so are regularly hitting infinite loops (we have all been there....and um... continue to find ourselves there ).
    Testimonial:
    pootle flump
    ur codings are working excelent.

  5. #5
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    Nice idea. I'm boneheaded and fairly often forgot the MoveNext when I wrote loops, so I'm a big user of code templates now. When I need one I just drop in one for "DAO Recordset with Loop" which I built with the MoveNext already in it. Saves a lot of head banging against keyboard.
    Paul

  6. #6
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Quote Originally Posted by pbaldy
    [I] often forgot the MoveNext when I wrote loops
    Lol - yes. After a few years of wondering wtf have I done this time I now make the movenext line the very first thing I write as soon as I start a recordset loop.

    Are you able to assign keyboard shortcuts or something similar to those? I do for T-SQL in SQL Server now (I cannot tell you how many typing hours I have saved). I would love the same in VBA.
    Testimonial:
    pootle flump
    ur codings are working excelent.

  7. #7
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    I use MZ Tools (free), in particular the error handling template and code templates, available with a right-click in VBA:

    http://www.mztools.com/index.htm

    Them and Smart Indenter I couldn't live without. Well, I could, but I wouldn't enjoy it.

    How did you do that in SQL Server?
    Paul

  8. #8
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Quote Originally Posted by pbaldy
    How did you do that in SQL Server?
    SQLPrompt (or PromptSQL - can't remember the rebranded name). $10 for the first version, free for the second, $195 for the third. Bought out by red-gate:
    http://www.red-gate.com/products/SQL_Prompt/index.htm

    Basically intellisense for SQL Server. Really useful - the snippets (as they call them) are the icing on the cake. Just don't accidently hit the "set to default" button after you have lovingly crafted 30 snippets and not backed them up

    I will look up MZ Tools - thank you
    Testimonial:
    pootle flump
    ur codings are working excelent.

  9. #9
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    I personaly use something called "ShortKeys Lite" which is the free version or ShortKeys (funnily enough). It's a very basic program that you can assign shortcuts to write out text.

    The one that always gets me is the Fetch Next in SQL Server
    Damn this loop is taking it's time...
    (1 hours later)
    Damn this loop is taking it's time...
    George
    Home | Blog

  10. #10
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    MZTool and Smart Indenter sounds very cool, Paul! Thanks for the tip!
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  11. #11
    Join Date
    May 2005
    Posts
    1,191
    Thanks for the tips guys. I just ended up watching a couple variables as I F8'd my way through the code in debug mode, it worked.
    Me.Geek = True

Posting Permissions

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