Retrieving Module Line Number

Mile-O

Back once again...
Local time
Today, 11:42
Joined
Dec 10, 2002
Messages
11,305
I've filled my database with an error handler routine that, on an error, sends details to an error log table such as date and time of error, error number, error description, the form on which the error occurred and who initiated the error.

This means that I can come into the database, review any errors that happen within the database and can then squash any programming bugs that I've not noticed.

As an extra, I'd also like to find out at which line in a module the error occurred - just to make debugging the database easier.

Any ideas?
 
This thread is a bit old, but i was looking to do this as well.

Here's what I found at vb123.com

Code:
Sub TestErL()

'This function shows how a line number can be printed out with an error

50   On Error GoTo Err_Wally
100  DoCmd.OpenForm "MyForm"

200  Exit Sub

Err_Wally:
  MsgBox "Error line number as follows ..." & Erl()

End Sub
 
Mile,

It will take some getting used to, but can't wait to see your
first post with the "new improved" line number code.

Seriously, if the Err object would give just the line of code
(like what's highlighted in yellow), it would be invaluable.
Maybe one of these next releases.

Wayne
 
Thanks, that's good to know but it wasn't what I was looking to do at the time.

Will bear it in mind for the future though. :cool:
 
fuzzygeek said:
Evidently according to the following article, you'll find no link to ERL in the help screen. When I selected ERL and hit F1, it took me to the ERR with no mention of ERL. After 95, it isn't in the help but is in the KnowledgeBase:

http://support.microsoft.com/default.aspx?scid=kb;en-us;148358

Thanks for the info:D
You can however, view erl in the object browser.
You just have to right click -> show hidden members
Not that it tells you much :p

Originally posted by Mile-O-Phile
Thanks, that's good to know but it wasn't what I was looking to do at the time.

Will bear it in mind for the future though.
It isn't? because i'm basically using it exactly how you described in your first post...

I know it's a bit of a pain having to add your own line numbers, but i'm only using it in modules i know i'm having problems with. And the line number arguement in my error handling procedure is optional, so i don't need to use it every time. Guess the only thing is you need to know which procedure the error occured in as well, unless you use a unique numbering system throughout an entire form/module?

Keep in mind you don't need to put a number on every line, so really there's no need to add a line number on a line like exit sub as your not likely to get any errors there... :D
 
What gets me about this whole thing, is that (if you have no
On Error statement), Microsoft knows the exact context that
the error is in. They know the module name, they know the
line of code, they know the part of the line of code. And
they do not make this info available to the developer.

To implement a "global" error handling (or logging) facility,
they just do not give us the information and tools to do it.

Wayne
 
Well, it is Microsoft u know... :D

btw, heres a global error handling example from a cd i have.
It covers just about everything.
 

Attachments

Users who are viewing this thread

Back
Top Bottom