dbTalk Databases Forums  

Module name identification in an error message

comp.databases.ms-access comp.databases.ms-access


Discuss Module name identification in an error message in the comp.databases.ms-access forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
rlntemp-gng@yahoo.com
 
Posts: n/a

Default Module name identification in an error message - 01-02-2008 , 11:57 AM






I am trying to dynamically populate the module name in the error
message.
Currently I populate a variable with hardcoded text:
strModuleName = "cmdFlushWorkTables_Click"

Per my code below, is there a way to populate strModulename
dynamically so that all I would need for the error message is the
message line itself? Is there some API call I can make that will
disclose the current module running so that when the error is raised,
that modulename would dynamically show up in my error message? If
there is a code sample for this, I would appreciate the assistance.

<begin code>
Private Sub cmdFlushWorkTables_Click()
On Error GoTo Err1

Dim blnReturn As Boolean
RunSQLReturn ("Delete * from tblCurrentMonthData")

Exit1:
Exit Sub

Err1:
strModuleName = "cmdFlushWorkTables_Click"
MsgBox Err.Number & ". " & Err.Description, vbExclamation,
gblPgmName & "-Error in " & strModuleName
Resume Exit1
End Sub
<end code>

Thanks.

Reply With Quote
  #2  
Old   
lyle
 
Posts: n/a

Default Re: Module name identification in an error message - 01-02-2008 , 01:28 PM






On Jan 2, 11:57 am, rlntemp-... (AT) yahoo (DOT) com wrote:
Quote:
I am trying to dynamically populate the module name in the error
message.
Currently I populate a variable with hardcoded text:
strModuleName = "cmdFlushWorkTables_Click"

Per my code below, is there a way to populate strModulename
dynamically so that all I would need for the error message is the
message line itself? Is there some API call I can make that will
disclose the current module running so that when the error is raised,
that modulename would dynamically show up in my error message? If
there is a code sample for this, I would appreciate the assistance.

begin code
Private Sub cmdFlushWorkTables_Click()
On Error GoTo Err1

Dim blnReturn As Boolean
RunSQLReturn ("Delete * from tblCurrentMonthData")

Exit1:
Exit Sub

Err1:
strModuleName = "cmdFlushWorkTables_Click"
MsgBox Err.Number & ". " & Err.Description, vbExclamation,
gblPgmName & "-Error in " & strModuleName
Resume Exit1
End Sub
end code

Thanks.
TTBOMK no one who has discovered a way to do this has yet shared his
or her knowledge.

I disagree with many or most when I say that very few VBA procedures
require any Error Handling Code. I use Error Handling Code only when I
set a state or handle, such as turning off screen updating with ECHO
or opening low level DOS files with Open, that I want to be sure is un-
set or released when there is an error

Error Handling Code is like a Class Module; both are often useless,
but we think they make us look good!




Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.