Results 1 to 3 of 3
  1. #1
    trb5016 is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Dec 2009
    Location
    Pennsylvania
    Posts
    71

    Error Handling

    So I have a (I think) fairly large database with lots of vba code. I want to go in and add error handling to all of it (I've got like 6000ish lines of code)

    Should every single procedure have an error handler?

    Like, if there's a command button that just has the line
    DoCmd.Openform "Form1"



    does that need all the error handler code in it?

    I mean, I can't foresee that code not working, but I'm sure it's possible. On the other hand that's going to be adding a lot of code...


    Opinions?

  2. #2
    Rawb is offline Expert
    Windows XP Access 2000
    Join Date
    Dec 2009
    Location
    Somewhere
    Posts
    875
    Unfortunately, every function that can throw an error will need it's own error handling. Generally speaking, that means any function running a DoCmd Event or that accesses a Recordset.

    As for the functions where you're just saving Records or opening or closing Forms, unfortunately you will need error handling in there. I've run into several instances when I've gotten a "Save changes" prompt (or similar) and had to hit Cancel. And, technically, canceling throws an error. . .

    Error handling - even in simple functions like those mentioned above - is especially important when you have users using the Access Runtime. The Runtime crashes on every unhandled error it comes across! This means that, if someone tries to close a Form using a button, gets a prompt, and hits Cancel. . . If you don't have error handling in that function, the Runtime's going to crash.

  3. #3
    trb5016 is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Dec 2009
    Location
    Pennsylvania
    Posts
    71

    Ahh I knew this deep down

    Yea, I figured this was going to be the case. I wish I had done this as I went along but I didn't even know how when I started making this haha.

    Thanks for the good advice.

    *sigh* it's my own fault lol

Please reply to this thread with any new information or opinions.

Similar Threads

  1. #error handling
    By mws5872 in forum Access
    Replies: 4
    Last Post: 05-12-2010, 07:06 AM
  2. Error Handling for newbie
    By smikkelsen in forum Access
    Replies: 4
    Last Post: 04-08-2010, 05:17 PM
  3. Replies: 2
    Last Post: 02-26-2010, 08:53 AM
  4. Handling dates in queries
    By mrk68 in forum Access
    Replies: 4
    Last Post: 03-23-2009, 06:35 AM
  5. Replies: 0
    Last Post: 03-05-2009, 12:27 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums