Results 1 to 5 of 5
  1. #1
    Join Date
    May 2003
    Location
    Costa Rica
    Posts
    40

    Angry Unanswered: On error continue ignoring the error

    Does someone know if into a module (Visual Basic for Microsoft Access) ives me error of something, what instruction is necessary to continue with the next line ignoring the error. without receiving a message. Please help....All the other problems I have send, are solved
    Last edited by Manuel Gimenez; 06-10-03 at 22:03.

  2. #2
    Join Date
    Jan 2003
    Location
    Rockville, MD
    Posts
    179
    Code:
    'This will skip over the error and continue to the next line of code
    On Error Resume Next
    
    '<put code here that may cause problems>
    
    'This will resume the "normal" error handling behavior
    On Error Goto 0

  3. #3
    Join Date
    Jan 2003
    Location
    Vietnam
    Posts
    188
    same idea as previous post but a different way to make sure that the subprocedure will resume without error message for a specific error. i would do this:

    Sub test()
    on error goto ErrorHandler
    'your codes go here

    exit sub

    ErrorHandler:
    if err.number=n then 'where n is the error code you want to ignore
    resume next
    else
    msgbox err.number
    End Sub

    you may need to get the error code first by msgbox error.number then decide the value of n
    hope this helps
    Last edited by qha_vn; 06-11-03 at 02:17.
    qha_vn

  4. #4
    Join Date
    Dec 2010
    Posts
    134
    Provided Answers: 1
    Hi

    Thanks for posting the Soooo useful code to ignore errors:
    On Error Resume Next

    Kill "C:\filepath\file.xls"

    On Error GoTo 0

    Really really helpful and so simple too. Just like moi!

    Do you know any tips for formating the Excel file, as part of the Access export?

  5. #5
    Join Date
    Nov 2012
    Posts
    32
    Quote Originally Posted by Raddle View Post
    Hi

    Thanks for posting the Soooo useful code to ignore errors:
    On Error Resume Next

    Kill "C:\filepath\file.xls"

    On Error GoTo 0

    Really really helpful and so simple too. Just like moi!

    Do you know any tips for formating the Excel file, as part of the Access export?
    Hi Raddle,

    I strongly discourage you from using On Error Resume Next.

    If you are relatively new to VBA programming the solution offered by qha_vn might seem complicated to you at first, but it is much, much better.

    Of course, If you just want to delete one file in a single command, On Error Resume Next is fine, but make sure to put On Error Goto 0 after it, or you'll regret it :-)

Posting Permissions

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