Results 1 to 2 of 2

Thread: error Handling

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2000
    Location
    Rhinelander, WI USA
    Posts
    59

    Post

    I have a general question i want to create some error handling but dont know how to go about doing it.... My greatest concern for error handling is that when a person deletes some information from a database and theres nothing to delete i get an error and thats the one id like to handle...

    Do You have any ideas?

    thanks

  2. #2
    New Member
    Join Date
    Jan 2000
    Location
    canada
    Posts
    15

    Post

    You have to set an Error handling branch at the first of your procedure. The first statement should read something like that

    On Error GoTo ErrHandler <--- Call it whatever you want

    Delete your record or whatever....

    Exit Sub

    ErrHandler: <--- Notice the same name!

    If (Err.Number = [Whatever Error number you get]) then

    Do some stuff.. like a message box!
    End If

    End Sub

    You can go endlessly checking the Error number for different errors and then handling them properly! Notice that there is an "Exit Sub" and then an "End Sub" after the Error handler. That is because if there is no error the code will not branch to the error handler but it will run through and execute all the IFs in the error handler even if there is no error and you don't need that to execute if there is no error. The Exit Sub prevents from executing useless code!

    Hope this can help my friend!

    [This message has been edited by VBfreak (edited 01-28-2000).]

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