Solved

Table holding error log -

Posted on 2011-03-18
8
286 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
ID: 35168727
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
ID: 35168790
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
ID: 35168807
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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 

Author Comment

by:Patrick O'Dea
ID: 35168871
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
 
LVL 57

Assisted Solution

by:Jim Dettman (Microsoft MVP/ EE MVE)
Jim Dettman (Microsoft MVP/ EE MVE) earned 100 total points
ID: 35171341
<<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
ID: 35172565
"(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
ID: 35172809
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
ID: 35172821
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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

Suggested Solutions

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

777 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