Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

On Error List Variables and Values - Possible? 1

Status
Not open for further replies.

sabloomer

Technical User
Aug 8, 2003
153
0
0
US
I have an Access application that has multiple subs to do different tasks. One sub is used to write to a log file as it works through the different processes. This sub is called from many other subs. As part of the error trapping, if there is an error the logging sub writes the error description to the log file.

Is it possible for the logging sub to figure out what variables are in memory and there values? I would like to write those to the log as well. I don't want to hardcode a reference to each variable because the error could have occurred in a handful of subs based on when the user was doing.

Any suggestions?

Thanks in advance,

sabloomer
 
Hello,

Why don't u pass the variables (along with the error data) that are used in the sub that has triggered the error to the sub that logs the error ?

Private sub TestIt()

on local error goto Error_Capture

dim strTest as string
dim intNumber as integer
...etc...


your code here


Error_Capture_Exit:
Exit Sub

Error_Capture:

'Here you call the sub that logs the error
'and u pass the errordata and the used variables in this
'sub to the error log
ErrorLog Err.Number, Err.Description, nameofsub, strTest, intNumber

Resume Error_Capture_Exit


End sub

Greets
 
KiaruB,

I was looking to avoid passing the variables to the ErrorLog because the number of variables will depend on which sub is calling it. So in some case I may only have 2 variables I need in the log and other times I may have 15 variables that need to be in the log.

I was hoping there would be a "Varaiables" collection, much like the QueryDef or TableDef collections that you can loop through.

Thanks,

sabloomer
 
You may use ParamArray in your ErrorLog procedure.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top