Where to capture error?

In the err_handler of my procedures I use:

Call ErrLog("frmMyForm", "Form_Current", "Error " & Err.Number & ": " & 
Err.Description)

I noticed that I can also capture the particular Err.Number and 
Err.Description in the ErrLog procedure, which would make the ErrLog call 
shorter:

Call ErrLog("frmMyForm", "Form_Current")

Is it a good idea to implement it like this or can I run into trouble?

Thanks,

Lars 

0
Lars
2/11/2010 9:52:09 PM
access 16762 articles. 3 followers. Follow

7 Replies
1194 Views

Similar Articles

[PageSpeed] 43

Since I wrote the ErrorLog routine,

http://www.datastrat.com/Code/Error.txt

I think I can answer that. The only place you may run into trouble is in 
Vista or possibly Windows 7 (since I haven't tested it there yet) if you are 
denied permissions to write to or create a file in the root of the C: drive. 
In that case, simple change the path in the code to write somewhere where 
the user does have permissions.
-- 
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com


"Lars Brownies" <Lars@Browniew.com> wrote in message 
news:hl1u6d$2d1b$1@textnews.wanadoo.nl...
> In the err_handler of my procedures I use:
>
> Call ErrLog("frmMyForm", "Form_Current", "Error " & Err.Number & ": " & 
> Err.Description)
>
> I noticed that I can also capture the particular Err.Number and 
> Err.Description in the ErrLog procedure, which would make the ErrLog call 
> shorter:
>
> Call ErrLog("frmMyForm", "Form_Current")
>
> Is it a good idea to implement it like this or can I run into trouble?
>
> Thanks,
>
> Lars 


0
Arvin
2/12/2010 3:31:44 AM
Thanks Arvin. Didn't know this code originated from you.

In my developers mdb I have made a link to the text file so that I can open 
it as a table. For that to work I had to change the comma separators in your 
code to |, as some error messages have comma's in them.

Lars

"Arvin Meyer [MVP]" <arvinm@mvps.invalid> schreef in bericht 
news:#cJViP5qKHA.3800@TK2MSFTNGP06.phx.gbl...
> Since I wrote the ErrorLog routine,
>
> http://www.datastrat.com/Code/Error.txt
>
> I think I can answer that. The only place you may run into trouble is in 
> Vista or possibly Windows 7 (since I haven't tested it there yet) if you 
> are denied permissions to write to or create a file in the root of the C: 
> drive. In that case, simple change the path in the code to write somewhere 
> where the user does have permissions.
> -- 
> Arvin Meyer, MCP, MVP
> http://www.datastrat.com
> http://www.mvps.org/access
> http://www.accessmvp.com
>
>
> "Lars Brownies" <Lars@Browniew.com> wrote in message 
> news:hl1u6d$2d1b$1@textnews.wanadoo.nl...
>> In the err_handler of my procedures I use:
>>
>> Call ErrLog("frmMyForm", "Form_Current", "Error " & Err.Number & ": " & 
>> Err.Description)
>>
>> I noticed that I can also capture the particular Err.Number and 
>> Err.Description in the ErrLog procedure, which would make the ErrLog call 
>> shorter:
>>
>> Call ErrLog("frmMyForm", "Form_Current")
>>
>> Is it a good idea to implement it like this or can I run into trouble?
>>
>> Thanks,
>>
>> Lars
>
> 
0
Lars
2/12/2010 5:56:08 AM
Strange thing, it seems that the err.number and err.description of the 
function where the error occured, aren't available anymore in the errlog 
function. I contstantly get the number 0 and description is empty. Maybe I 
did something wrong with testing or should it work?

Thanks,

Lars

"Arvin Meyer [MVP]" <arvinm@mvps.invalid> schreef in bericht 
news:#cJViP5qKHA.3800@TK2MSFTNGP06.phx.gbl...
> Since I wrote the ErrorLog routine,
>
> http://www.datastrat.com/Code/Error.txt
>
> I think I can answer that. The only place you may run into trouble is in 
> Vista or possibly Windows 7 (since I haven't tested it there yet) if you 
> are denied permissions to write to or create a file in the root of the C: 
> drive. In that case, simple change the path in the code to write somewhere 
> where the user does have permissions.
> -- 
> Arvin Meyer, MCP, MVP
> http://www.datastrat.com
> http://www.mvps.org/access
> http://www.accessmvp.com
>
>
> "Lars Brownies" <Lars@Browniew.com> wrote in message 
> news:hl1u6d$2d1b$1@textnews.wanadoo.nl...
>> In the err_handler of my procedures I use:
>>
>> Call ErrLog("frmMyForm", "Form_Current", "Error " & Err.Number & ": " & 
>> Err.Description)
>>
>> I noticed that I can also capture the particular Err.Number and 
>> Err.Description in the ErrLog procedure, which would make the ErrLog call 
>> shorter:
>>
>> Call ErrLog("frmMyForm", "Form_Current")
>>
>> Is it a good idea to implement it like this or can I run into trouble?
>>
>> Thanks,
>>
>> Lars
>
> 
0
Lars
2/12/2010 4:40:59 PM
"Lars Brownies" <Lars@Browniew.com> wrote in message 
news:hl40b0$59k$1@textnews.wanadoo.nl...
> Strange thing, it seems that the err.number and err.description of the 
> function where the error occured, aren't available anymore in the errlog 
> function. I contstantly get the number 0 and description is empty. Maybe I 
> did something wrong with testing or should it work?


It should work, provided you don;t clear the error between the time it is 
raised and the time it is displayed or printed.  Post the exact code of your 
ErrLog function.

-- 
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)

0
Dirk
2/12/2010 4:53:51 PM
In a module I have the following function:

Public Function ErrLog(strObj As String, strRoutine As String)
On Error GoTo Err_Handler

Dim strErr as String

strErr = "Error " & Err.Number & ": " & Err.Description

MsgBox strErr & cLine & "(Object: " & strObj & ". Procedure: " & strRoutine 
& ".)", vbExclamation, cAppName
strErr = Replace(strErr, Chr(10), ", ")

Open strPathApp & cAppAbbr & "-FE\Log.txt" For Append As #1
Print #1, Format(Now, "dd/mm/yyyy hh:nn:ss") & "|Object: " & strObj & 
"|Routine: " & strRoutine & "|" & strDepartment & "|" & strUser & "|" & 
strErr
Close #1

Exit_Func: Exit Function
Err_Handler:
    MsgBox Err.Description & " in ErrLog." & " " & strObj & " " & 
strRoutine, vbExclamation, cAppName
    Resume Exit_Func
End Function

Thanks,

Lars


"Dirk Goldgar" <dg@NOdataSPAMgnostics.com.invalid> schreef in bericht 
news:e$G12PArKHA.5940@TK2MSFTNGP02.phx.gbl...
> "Lars Brownies" <Lars@Browniew.com> wrote in message 
> news:hl40b0$59k$1@textnews.wanadoo.nl...
>> Strange thing, it seems that the err.number and err.description of the 
>> function where the error occured, aren't available anymore in the errlog 
>> function. I contstantly get the number 0 and description is empty. Maybe 
>> I did something wrong with testing or should it work?
>
>
> It should work, provided you don;t clear the error between the time it is 
> raised and the time it is displayed or printed.  Post the exact code of 
> your ErrLog function.
>
> -- 
> Dirk Goldgar, MS Access MVP
> Access tips: www.datagnostics.com/tips.html
>
> (please reply to the newsgroup)
> 
0
Lars
2/12/2010 5:11:49 PM
"Lars Brownies" <Lars@Browniew.com> wrote in message 
news:hl424p$60c$1@textnews.wanadoo.nl...
> In a module I have the following function:
>
> Public Function ErrLog(strObj As String, strRoutine As String)
> On Error GoTo Err_Handler


Bang!  There's your smoking gun.  Executing an "On Error" statement 
automatically clears the Err object.  Change the procedure to capture the 
current error values *before* executing that statement:

'------ start of revised code ------
Public Function ErrLog(strObj As String, strRoutine As String)

    Dim strErr as String
    Dim intFileNo As Integer

    strErr = "Error " & Err.Number & ": " & Err.Description

    On Error GoTo Err_Handler

    MsgBox _
        strErr & cLine & "(Object: " & strObj & _
            ". Procedure: " & strRoutine & ".)", _
        vbExclamation, _
        cAppName

    strErr = Replace(strErr, Chr(10), ", ")

    intFileNo = FreeFile()
    Open strPathApp & cAppAbbr & "-FE\Log.txt" For Append As #intFileNo

    Print #intFileNo, _
        Format(Now, "dd/mm/yyyy hh:nn:ss") & _
        "|Object: " & strObj & _
        "|Routine: " & strRoutine & "|" & strDepartment & _
        "|" & strUser & "|" & strErr

    Close intFileNo

Exit_Func:
    Exit Function

Err_Handler:
    MsgBox _
        Err.Description & " in ErrLog." & " " & strObj & " " & strRoutine, _
        vbExclamation, _
        cAppName
    Resume Exit_Func

End Function
'------ end of revised code ------

Note:  I also removed your hard-coding of 1 for the file number, and used 
FreeFile() to get the first free number.  Hard-coding the file number is a 
bad practice, because there could be circumstances in which the number 1 may 
already be in use.

-- 
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)

0
Dirk
2/12/2010 5:30:57 PM
Wow! Thanks a lot Dirk for the lesson.

Lars

"Dirk Goldgar" <dg@NOdataSPAMgnostics.com.invalid> schreef in bericht 
news:uF2NmkArKHA.4284@TK2MSFTNGP04.phx.gbl...
> "Lars Brownies" <Lars@Browniew.com> wrote in message 
> news:hl424p$60c$1@textnews.wanadoo.nl...
>> In a module I have the following function:
>>
>> Public Function ErrLog(strObj As String, strRoutine As String)
>> On Error GoTo Err_Handler
>
>
> Bang!  There's your smoking gun.  Executing an "On Error" statement 
> automatically clears the Err object.  Change the procedure to capture the 
> current error values *before* executing that statement:
>
> '------ start of revised code ------
> Public Function ErrLog(strObj As String, strRoutine As String)
>
>    Dim strErr as String
>    Dim intFileNo As Integer
>
>    strErr = "Error " & Err.Number & ": " & Err.Description
>
>    On Error GoTo Err_Handler
>
>    MsgBox _
>        strErr & cLine & "(Object: " & strObj & _
>            ". Procedure: " & strRoutine & ".)", _
>        vbExclamation, _
>        cAppName
>
>    strErr = Replace(strErr, Chr(10), ", ")
>
>    intFileNo = FreeFile()
>    Open strPathApp & cAppAbbr & "-FE\Log.txt" For Append As #intFileNo
>
>    Print #intFileNo, _
>        Format(Now, "dd/mm/yyyy hh:nn:ss") & _
>        "|Object: " & strObj & _
>        "|Routine: " & strRoutine & "|" & strDepartment & _
>        "|" & strUser & "|" & strErr
>
>    Close intFileNo
>
> Exit_Func:
>    Exit Function
>
> Err_Handler:
>    MsgBox _
>        Err.Description & " in ErrLog." & " " & strObj & " " & strRoutine, 
> _
>        vbExclamation, _
>        cAppName
>    Resume Exit_Func
>
> End Function
> '------ end of revised code ------
>
> Note:  I also removed your hard-coding of 1 for the file number, and used 
> FreeFile() to get the first free number.  Hard-coding the file number is a 
> bad practice, because there could be circumstances in which the number 1 
> may already be in use.
>
> -- 
> Dirk Goldgar, MS Access MVP
> Access tips: www.datagnostics.com/tips.html
>
> (please reply to the newsgroup)
> 
0
Lars
2/12/2010 5:48:35 PM
Reply:

Similar Artilces:

Error when tagging emails off line in Outlook
When we tag an email to a CRM (3.0) object in Outlook while working off line and error occurs the next time you attempt to synch. The error shows the tagged email with the option of going on line and loosing the relationship or continue to work off line. Anyone else experience this problem? ...

TreeView NodeClick (VBA): Throwing Mysterious Error
I tried posting this in microsoft.public.activex.controls, but no luck. Upon reflection, it seems better suited to .access because it seems to be something about how MS Access VBA handles a certain type of error. --------------------------------------------------------- This error starts popping every so often following changes to various VBA routines (not to NodeClick, however) in the same form. Something about "The expression NodeClick...." Screen snap at: http://tinyurl.com/2pmbne I'll revert to the prior version, key in the same changes, and all will be well. It does no...

Inbox Repair Tool error
A member of our staff overflowed his Inbox last week. A quick check revealed that it was slightly over the 2Gb suggested limit. I ran the 2GB Truncate Utility, and then ran the Inbox Repair Tool. When the repair tool gets about halfway through Phase 6 of 8, it stops and I get the error message "An error has occurred which caused the scan to be stopped. No changes have been made to the scanned file." I've gone back to the original PST file three times now to each time cut off more and more excess with the 2GB utility, but each time I get the same error message with ...

Errors 2448 and 3075!
I have a search comand button and it works most of the time, excpet with one name (so far) O'Shea. It comes up with the following error message: Run- time error '2448' You can't assign a value to this object. The debugger highlights this: Me.Filter = "[Surname] LIKE '*" & RetVal & "*'" However othertimes, it says this: Runt-time error '3075' Syntax error (missing operator) in query expression "[Surname] LIKE '*O'Shea*". Any ideas? Here's the whole section: Private Sub Command187_Click() Dim R...

error value in axis
I am trying to plot a chart for varying number of weeks. I use the formula =IF(J63=0,NA(),J63-1) to stop with zero th week starting from the week I define. I also use similar formulas for getting data i.e =IF(ISERROR(VLOOKUP($K64,$A:$D,2)),NA(),VLOOKUP($K64,$A:$D,2)), where k64 indicates week number. The problem now is the data line stops with 'NA' values as expected, but the axis which contains week number shows 'NA' after the week numbers. Any ways to fix this. Now you need dynamic names (aka named ranges) that know where the numerical data ends, and use these names a...

Outlook error #41
When I try to start Outlook, I get the following "The application failed to initialize properly (0xC0150002). Click on OK to terminate the application. How do I correct this? Hi Leon, please read this information from MS http://support.microsoft.com/default.aspx?scid=kb;EN-US;817117 or this one http://support.microsoft.com/default.aspx?scid=kb;EN-US;822520 -- Ich habe nichts gemacht, gestern gings noch! Bitte in den Newsgroup antworten damit jeder etwas davon hat. Bravestar@Datenschutzministerium.de "Leon" <anonymous@discussions.microsoft.com> schrieb im Newsbeitrag...

Error Message ...
I have emails that are sitting in the Outbox and will not be sent, this is the message that come on my screen as a pop-up: Message could not be displayed Windows Mail encountered an unexpected problem while displaying this message. Check your computer for low memory or low disk space and try again. It will not let me delete or move the email. What do I need to do to correct this? Try posting this in Windows Mail news group - this is not one of them. Outlook is a part of Microsoft Office and is what this group supports. Windows Mail is a part of Internet Explorer and has its own news g...

Could not synchronise record error.
Version: 2008 Operating System: Mac OS X 10.6 (Snow Leopard) Processor: Intel Email Client: Exchange I'm running Entourage Web Services Edition, and syncing with Exchange 2008. It all appears to be working, but I keep getting an error message: <br><br>--- <br> Could not synchronize record: Returned mail: User unknown to Exchange server: Exchange <br> --- <br><br>It registeres in the log about every half an hour, even though it's set to send/receive every 5 mins. <br><br>Has anyone else struck this? Anyone know the cause/solution? ...

email capture
I'm having a problem with Outlook not pulling the mail off my pop server. When I do a send and receive the mail is identified, "grabs" the messages like it's doing a download but when it reaches the end I'm getting an unknown error message. Any thoughts? 1) First, try to set up Outlook Express to download the email set. Sometimes it has better luck. 2) Another way is to clear the queue manually. This is technical, and not really recommended by anyone, but you may have a stuck message... Telnet to get it... (this method permanently deletes messages before you c...

Median of Even Set; How to Capture them?
Hi everyone, Say I have a dat set such as: 4 5 6 7 The median is (5+6)/2=5.5! However, I am not interested in the answer here, but the 5 and the 6!!! Is there an excel function or way to do so? Thanks alot, Mike Do you want the output in one single cell or in 2 separate cells? Mike Wrote: > Hi everyone, > > Say I have a dat set such as: > > 4 > 5 > 6 > 7 > > The median is (5+6)/2=5.5! > > However, I am not interested in the answer here, but the 5 and the > 6!!! > > Is there an excel function or way to do so? > > Thanks alot, ...

Microsoft Visual C++ Runtime Library Error Message
I have a user who was in Outlook, and upon exiting, he would get the Microsoft Visual C++ Runtime Library Dialog box that pops up, and it says "C:\Program....outlook.exe. Abnormal Program Termination." Any ideas on what could be causing this to come up. How do I fix it? Please help! ...

Capture user selection of font
If I put a font combo box on a Ribbonbar is there a way for me to capture the user's font choice? I need to capture that choice and use it in a macro. Whate *exactly* are you trying to achieve with your macro? -- <>>< ><<> ><<> <>>< ><<> <>>< <>><<> Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org <>>< ><<> ><<> <>>< ><<> <>>< <>><<> "dplaut"...

error message #5
installed publisher and when i try to start it, i get the following message: MSPUB caused an invalid page fault in module KERNEL32.DLL at 017f:bff87ed3. Registers: EAX=008afe28 CS=017f EIP=bff87ed3 EFLGS=00010207 EBX=008afe28 SS=0187 ESP=007b0000 EBP=007b0130 ECX=007b01b4 DS=0187 ESI=81747bd8 FS=114f EDX=bff76855 ES=0187 EDI=007b01dc GS=0000 Bytes at CS:EIP: 55 a1 e0 9c fc bf 8b ec 83 ec 6c 53 56 57 8b 30 Stack dump: ffecbad7 007b0030 007b0014 00000006 00000006 c000001d 00000000 00000000 00000017 00000000 c1631b00 cce42f70 0001001f 00000000 00000000 00000000 what do i need to do? What ...

Change Data Capture: Preserve capture instance data when adding co
When a new column is added to table that is configured for change data capture (cdc), the capture instance table will not have the new column until cdc is disabled and re-enabled for the source table. In the process the existing capture instance is dropped. I thought I could copy existing data out to a temp table and then copy back using the following SQL. However, other CDC meta information, such as the cdc.change_tables.start_lsn, becomes invalid. How can the capture instance history be preserved, using the same capture instance name, if at all? Thanks, Rich /*...

Excel 2000 run-time error '7':
I am running Office 2K and just today, every spreadsheet I open I get the following error: "Microsoft Visual Basic" "Run-time error '7': " "Out of memory". Now I am running a 1.6GHz machine with .5GB RAM. I do not have any special addin's or anything non-standard from the normal office 2K professional install. As a note, after clicking "End" the spreadsheet opens. Occasionally, certain sheets only show 4 of the 8-10 worksheets. Any help would be appreciated. ...

preTranslateMessage error
I'm learning how to use pretranslateMessage in c++ for an mfc app. but it keeps giving me two errors and I can't find a good tutorial on it. it says: PhysicsMath error LNK2005: "public: virtual int __thiscall CPhysicsMathDlg::PreTranslateMessage(struct tagMSG *)" (?PreTranslateMessage@CPhysicsMathDlg@@UAEHPAUtagMSG@@@Z) already defined in PhysicsMath.obj and PhysicsMath fatal error LNK1169: one or more multiply defined symbols found anyone know what it means? dave "Deej" <davidhere40@hotmail.com> wrote in message news:7sednROg4_wLPmmiRVn-jg@comcast.com.....

How to handle @@error=1785
I'm trying to add a FK constraint to a table and get error 1785 " Introducing FOREIGN KEY constraint 'fk_blah' on table my_table' may cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY constraints. " I've tried put the alter table statement in a tran and roll it back if @@error=1785 but I still get the error. Not sure if there is any way to handle this. If there was it would be good because I've actually got 100 similar alter table statements to be run in and my list stops at the f...

Fixed Asset Retirement date error
Hi all, I get this message when I try to retire one asset: "Retirement Date must be in or before the current fiscal year for any book." The Corporate book is current year, but the tax books (Federal, AMT, ACRS) are still on previous year as our tax accountants are not done with the tax returns yet. Do I have to wait to retire until ALL my books have the Year End Process routine completed for all books? Thanks, ...

money 2005 install error
I have two account on xp pro sp2, Administrator and my user account which is an Administrator account. Before the Money 2005 Deluxe install starts, it alerts with an error that I must sign on with power user or administrator privileges??? I have logged on directly as Administrator and still get the error. Created a new admin account, same error?? Any ideas?? well, who would have though microsoft hard coded the "Program Files" directory into the install checks? Since I have my program files on a different partition I had to create a dummy "Program Files" folder on t...

Capturing date/time modified on a form?
I have a form where staff can go and add student information, I would like to be able to capture when and if the form has been modified. We are running reports on students with certain behaviours right now but we don't know how up-to-date the data is if we don't capture if it's been changed recently. I added TimeModified and DateModified to my main table and put the fields on my form that I need it to capture but I'm not sure how to actually get it to fill those fields once data has been modified, any help would be appreciated. Monique Duane OK, what I've done now...

getting error at time of XmlSerialization
Hi Friends, My work is stuck up because of this unresolvable and unbelievable Error. I'm trying to Serialize my Class object using XmlSerialization. And at below line, I m getting "error File or assembly name xxxxxxx.dll, or one of its dependencies, was not found.." ///I got error at this point XmlSerializer xmlSerializer = new XmlSerializer(typeof(myObject)); Error: {"File or assembly name xxxxxxx.dll, or one of its dependencies, was not found." } As this is an IO error and I'm not using any external file. I am not understand why this is happen with my code. ...

OL 2002 Error Message
Please help. Using Outlook 2002, Win XP Pro, Norton System Works, have 2 problems, and don't know if they are related to one another, and dont' know how to fix. I continually get the following Error Message. I have one e-mail account, and made the the recommended changes in the following article hoping it would resolve. BEFORE the changes I received up to 30 duplicates of EACH e-mail. The changes have not corrected my Error Message or Duplicate mail. The mail stays on the server even tho my settings are to NOT leave on server? Error Message: (0x800CCC90) Your Incoming (POP3) E-Mail...

code error 80048823
hi i have tried every thing to fix it reset my password but i wont work and i dont have a alternate email adress option can you please help mee and i tried looking at all solution i stiil aint workink helpp please ... ...

Rules in Error
Rules in Error popup box appears - everytime I open Outlook Under Rule - Server-Requested Client Action Under Error - MoveCopy, Unable to create dest msg. I have deleted all of my rules and it still appears. Any suggestions? Thanks Mark ...

Capture signature
I have a Ingenico 6550 signature capture device. When i sign on the device, it didn't capture the name. The display and the card capture worked, only the signature part doesn't work. I set the device name and everything, it loaded the form, and the tab for the signature on the pos poped up. I use the form designer to test the capture device it worked. The signature show on the form designer. I don't know what could go wrong. Could anyone help!!! By the way i am using RMS 1.3. "TJW" wrote: > I have a Ingenico 6550 signature capture device. When i sign on...