Solved

How can I retreive the line, module and prodedure where an error occurs?

Posted on 2004-04-25
4
134 Views
Last Modified: 2010-05-02
Please give a detailed example

I want to have a fuction that will return:
The Module or Form that the error occurs in.
The Procedure that the error occurs in.
The line the error occurs in.
And of course in will return Err.Number and Err.Description.

0
Comment
Question by:brianshoenhair
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 8

Expert Comment

by:plq
ID: 10911248
Basically its not possible, but...

From an exe you have to put context information in your code.

This can be

(a) a global which sets a context string
(b) a stack class which adds a context every time you do a call, and removes the context every time you return

option (b) can be a performance hit. option (a) doesn't always give you the info you need. so its down to what your requirements are.

From VB you can set tools - options - break on all errors. Then the debugger will break on the error line. I guess you knew that already ?
0
 
LVL 18

Accepted Solution

by:
Sethi earned 60 total points
ID: 10911374
I use third party tool named CodeSmart 2003. The error handler's written with this tool can tell me the exact line and place of the error.
0
 
LVL 9

Assisted Solution

by:dancebert
dancebert earned 40 total points
ID: 10914216
The undocumented Erl() function will return the line number where the error occured.  For this to work you have to use line numbers.  If the line with the error does not have a line number, Erl() returns the last numbered line before the error.  This function was documented in earlier versions of VB.  
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question