Solved

Table holding error log -

Posted on 2011-03-18
8
284 Views
Last Modified: 2012-05-11
Hi,
(This is probably a bit lazy but...)

I have a table that is log of all errors that occur.
A fundamental part of this simple log is ;

AuditDetails = AuditDetails & "Form : " & Screen.ActiveForm.Name & "     User: " & Environ("Username")

I do NOT pass any actual data to the Audit function.
You will note that the "ActiveForm" is referred to.

Question: Is there any other info such as "ActiveForm" that I could refer to.?  For example, I was wondering could I some how refer to some "primary index" of a table??

I am hoping that I can add some additional helpful info to the error message without actually passing any to it!     (I already know the user, the time and the form ...)
0
Comment
Question by:Patrick O'Dea
  • 4
  • 3
8 Comments
 
LVL 75

Expert Comment

by:DatabaseMX (Joe Anderson - Access MVP)
Comment Utility
Well sure:

Err.Number
Err.Description


ERL  ... which is the error Line Number ... and you can use the free MZTools to easily add line numbers to your code:

http://www.mztools.com/v3/mztools3.aspx

This is just for starters ...

Not sure why you would need the Primary Index ... which in general would have nothing to do with any error per se ...?

mx
0
 

Author Comment

by:Patrick O'Dea
Comment Utility
Thanks databaseMX,

... I appreciate your interest.

Example:  A user is keying contact information into a customer record ... suddenly an error occurs.....It would be very nice to know the unique  customerID.

E..g Customer C0001 was being processed when the error occurred.
0
 
LVL 75

Expert Comment

by:DatabaseMX (Joe Anderson - Access MVP)
Comment Utility
I see.  But that would not necessarily apply to every place/instance an unexpected error might occur.  Sure ... on a specific Form maybe, but not elsewhere.

mx
0
 

Author Comment

by:Patrick O'Dea
Comment Utility
Yes, I know mx,

The nature of my query may mean that there is no real answer.

However, I just wanted to make sure I did not miss anything.

(I will use err.number & description)
ActiveForm is of a great help but I guess that that may be the only such one.

I guess that is it???

(... currently browsing MZtools..)
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 57

Assisted Solution

by:Jim Dettman (Microsoft MVP/ EE MVE)
Jim Dettman (Microsoft MVP/ EE MVE) earned 100 total points
Comment Utility
<<Question: Is there any other info such as "ActiveForm" that I could refer to.?  For example, I was wondering could I some how refer to some "primary index" of a table??>>

  I think if you do as Mx suggested (adding the line number), you'll find that you can pin-point errors quickly.  To add to that I also do this:

Const ModuleName = "OCS_AppUtilityFunctions"

at the top of each module and add:

        Const RoutineName = "SetCurrentCompany"
        Const Version = "1.1.0"

 to the top of each procedure.  The call then to my error handler is:

ErrorHandler:
130     UnexpectedError ModuleName, RoutineName, Version, Err.Number, Err.Description, Err.Source, VBA.Erl
140     Resume Exit_Sub

  Which pin-points things very well.

  Also, you might be interested in this:

http://www.everythingaccess.com/vbwatchdog.htm

  which is a global error handler for VBA.

JimD.
0
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Access MVP) earned 400 total points
Comment Utility
"(adding the line number), "

When I discovered mzTools a few years back, I started adding the Line Numbers.  This has made a *huge* difference in tracking down errors, an subsequently fixing the issue ... especially in functions with a LOT of code.  Just knowing the function name - not that helpful per se.  I once made a $100 donation to MZTools.

And (as noted) ... although a bit more advanced, I *highly* recommend Wayne's vbWatchdog for the ultimate error handling functionality, which I have been slowly integrating into my apps.

http://www.everythingaccess.com/vbwatchdog.htm (read my review).  However ... good to start with basic error handling as you are doing - to get the background.

" To add to that I also do this:"
Actually ... MZTools can add that automatically for you - by creating a custom error handling template and using the 'replacement variables' - see image - eg {PROCUDURE_NAME} .  Same goes for Procedure Headers, Module Headers, etc.  Soooooo many cool features.

RE:"I guess that is it??? "
Well, there is also Screen.ActiveControl ... but again, that only applies to certain cases.

mx
Capture1.gif
0
 

Author Closing Comment

by:Patrick O'Dea
Comment Utility
Thanks againmx,

I have downloaded MZ and this could be a new adventure. My knowledge of Access is incrementing by about 20% per month at the moment ... mainly thanks to EE.
0
 
LVL 75

Expert Comment

by:DatabaseMX (Joe Anderson - Access MVP)
Comment Utility
You are welcome.

"about 20% per month at the moment"
MZTools will put you on Access steroids !

Thanks for using Experts Exchange ...

mx
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

763 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now