Results 1 to 11 of 11
  1. #1
    d9pierce1 is offline Expert
    Windows 10 Access 2016
    Join Date
    Jan 2012
    Location
    Oklahoma
    Posts
    754

    Error Code Question

    Hi all,
    I was just wondering if it is possible to put the code below into a module and then call on the module in error handling? It would save a lot of lines to add to each sub that needed it?

    Code:
    Private Sub Name()    
    On Error GoTo Err_Handler
    
    
    'Your Code
    
    
    Exit_Handler:
        Exit Sub
    Err_Handler:
        Select Case Err
            Case Else
                MsgBox "Error " & Err & ": " & Error$, vbExclamation, "Name()"
                Resume Exit_Handler
        End Select
    End Sub
    Not sure if its possible or not but seemed like a great idea to me?


    Sure would save a lot of lines.....

    Thanks
    Dave

  2. #2
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    You're asking if you can use code to handle errors from just about any form? Yes, but not what you showed IMO.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    moke123's Avatar
    moke123 is online now Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,643
    If you want to save on keystrokes, get a copy of MZTools. I wouldn't code without it. You can insert error handlers with a click of a button. You can also save your own code templates that you use frequently and insert with 1 click.
    I would also recommend Smart indenter

    https://www.mztools.com/v8/mztools8.aspx
    http://www.oaltd.co.uk/Indenter/Default.htm

  4. #4
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,530
    Quote Originally Posted by moke123 View Post
    If you want to save on keystrokes, get a copy of MZTools. I wouldn't code without it. You can insert error handlers with a click of a button. You can also save your own code templates that you use frequently and insert with 1 click.
    I would also recommend Smart indenter

    https://www.mztools.com/v8/mztools8.aspx
    http://www.oaltd.co.uk/Indenter/Default.htm
    I thought that MZTools used to be free but I see they are charging for it now.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  5. #5
    moke123's Avatar
    moke123 is online now Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,643
    Quote Originally Posted by Bob Fitz View Post
    I thought that MZTools used to be free but I see they are charging for it now.
    I was lucky enough to get it before they started charging. Its an old version but works flawlessly.
    I think I would buy it if I had to. Its well worth it.

  6. #6
    d9pierce1 is offline Expert
    Windows 10 Access 2016
    Join Date
    Jan 2012
    Location
    Oklahoma
    Posts
    754
    That is definately worth the cost of it! Love It and Thanks for the information

  7. #7
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,530
    Quote Originally Posted by moke123 View Post
    I was lucky enough to get it before they started charging. Its an old version but works flawlessly.
    I think I would buy it if I had to. Its well worth it.
    Yes. I agree totally. I got mine many years ago
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  8. #8
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    I did upgrade and pay for v8 and its great...when I need it. However, almost all the functionality I need was in the free version 3
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  9. #9
    moke123's Avatar
    moke123 is online now Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,643
    I had a mild freakout a while back when I got a new computer in office and a new computer at home. Re-Installed Access but couldn't find my copy of MZTools ver.3. I search through a dozen old hard drives and luckily found it.
    I copied it to few cd's and my back up drive so i'd never lose it again. Same with Smart Indenter just in case it becomes a paid version too.

  10. #10
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,530
    Quote Originally Posted by moke123 View Post
    I had a mild freakout a while back when I got a new computer in office and a new computer at home. Re-Installed Access but couldn't find my copy of MZTools ver.3. I search through a dozen old hard drives and luckily found it.
    I copied it to few cd's and my back up drive so i'd never lose it again. Same with Smart Indenter just in case it becomes a paid version too.
    I wish I'd had your foresight as I have a problem with my installation of MZTools. I think the only fix will be to buy the latest version
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  11. #11
    moke123's Avatar
    moke123 is online now Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,643
    Quote Originally Posted by Bob Fitz View Post
    I wish I'd had your foresight as I have a problem with my installation of MZTools. I think the only fix will be to buy the latest version
    If I recall correctly, I had a problem when I first installed it on win10. I had to jump through hoops to run it as an administrator.

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

Similar Threads

  1. Replies: 0
    Last Post: 10-10-2018, 12:28 PM
  2. Replies: 3
    Last Post: 05-10-2018, 07:48 AM
  3. VBA Code Returning Error Run Time Error 3061
    By tgwacker in forum Access
    Replies: 2
    Last Post: 11-24-2013, 11:00 AM
  4. Error Handling Question - On Error Goto
    By redbull in forum Programming
    Replies: 7
    Last Post: 12-06-2012, 07:54 AM
  5. Another key code question
    By crowegreg in forum Forms
    Replies: 5
    Last Post: 07-01-2012, 05:26 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