Results 1 to 5 of 5

Thread: Ok, I did the prerequisite help search bt am still unsure about on error resume next

  1. #1

    Thread Starter
    Hyperactive Member Al Smith's Avatar
    Join Date
    May 1999
    Location
    Marcellus, MI. USA
    Posts
    330

    Post

    When an "On Error Resume Next" is issued, is it only active for the one statement following the error or does it remain active for the entire module?
    That is will errors generated by code several lines below the ...Resume Next also resume?
    Thanks,
    Al.


    ------------------
    A computer is a tool, not a toy.
    <A HREF="mailto:[email protected]
    [email protected]">[email protected]
    [email protected]</A>


  2. #2
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923

    Post

    I do beleive it will pick up any subsequent errors and move to the next line. Infact i'm almost positive.

    Regards,

    ------------------
    - Chris
    [email protected]
    If it ain't broke - don't fix it

  3. #3
    Addicted Member
    Join Date
    May 1999
    Location
    Californ-I- A
    Posts
    207

    Post

    It works for all the code fallowing that statement within a given sub or function. (ie if you have that in a Form_Resize event, when the form resizes so small that controls begin to overlap then an error will rise. But that on error resume next will just ignore it and go on to the next line of code)

    ------------------
    Micah Carrick
    http://micah.carrick.com
    [email protected]
    ICQ: 53480225


  4. #4
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Post

    Here is a piece of code you can step through and see what happens.
    Code:
        Dim intMySalary As Integer
        Dim intA As Integer
        Dim intB As Integer
        Const I_WISH = 150000
        
        On Error GoTo ErrorRoutine
        
        intMySalary = I_WISH
        
        MsgBox "I don't get executed"
    AfterOverFlow:
        MsgBox "Resumed after overflow"
        
        On Error Resume Next
        intMySalary = I_WISH
        
        MsgBox "Now I do get executed but intMySalary is " & intMySalary
        
        intA = 25
        intB = 60
        MsgBox intA + intB
        
        On Error GoTo ErrorRoutine
        'This will put us into a loop because I'm raising 25 to the 60th
        'power and we get overflow again
        intMySalary = intA ^ intB
        
        Exit Sub
    ErrorRoutine:
    
        Select Case Err.Number
            Case 6 'Overflow
                MsgBox "In your dreams!"
                Resume AfterOverFlow
            Case Else
                MsgBox Err.Number & " - " & Err.Description
        End Select
    ------------------
    Marty

    [This message has been edited by MartinLiss (edited 01-15-2000).]

  5. #5

    Thread Starter
    Hyperactive Member Al Smith's Avatar
    Join Date
    May 1999
    Location
    Marcellus, MI. USA
    Posts
    330

    Post

    Rats! I was afraid of that.
    Will On Error Goto 0 disable the resume next?

    Here's my dilemma. I have a program that creates individualized spreadsheets for various remote warehouses across the country. Prior to saving the new sheets to the warehouse's network folders, the old sheets are deleted (Killed). At times the warehouse managers are working with the spreadsheets and, since the sheets are open, the Kill command errors out. I used the "on error resume next" to save the new sheet even if the old sheet can't be deleted. But I still need to trap other errors.
    Thanks again.
    Al.



    ------------------
    A computer is a tool, not a toy.
    <A HREF="mailto:[email protected]
    [email protected]">[email protected]
    [email protected]</A>


Posting Permissions

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



Click Here to Expand Forum to Full Width