Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Jan 2001
    Location
    Portland, Maine, USA
    Posts
    173
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Getting the procedure name that an error occurs in (XP/SP-2)

    I want to display the procedure name in the title bar of a msg box whenever there is an error. Is there an easy way to refer to the first line of the current procedure or something when an error occurs? In the past I have manually typed in the procedure name in the title args of the error msg box, there must be an easier way!

    Thanks for any suggestions,
    Don

  2. #2
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Getting the procedure name that an error occur

    I use an Access Add-in called MZ tools. This will automatically generate error code for a procedure that includes the procedure name in the body of the message. You can customise the way this works, so I think you could change it so that the procedure name was in the title box if you want.

    You can download it from : http://www.mztools.com/

    Here is an example:

    MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure sbQuicksearch of VBA Document Form_frmMainMenu"
    Regards
    John



  3. #3
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Getting the procedure name that an error occur

    This had me confused for a while today. I copied a procedure from one form to another complete with error handling.

    When errors occurred the message included the name of the form I wasn't using, making me think something very strange was going on, until I remembered that the name of the wrong form was written into the error code.
    Regards
    John



Posting Permissions

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