How to get control event name? (1 Viewer)

bulrush

Registered User.
Local time
Today, 13:23
Joined
Sep 1, 2009
Messages
209
A2003 on WinXP

In my control events I have a standard error routine called DispError which needs the name of the event that generated the error. A typical control event looks like this:
Code:
Private Sub Form_Timer()
Dim procname As String

On Error GoTo MyError
procname = "Form_Timer"

Me!lblClock.Caption = Format(Now, "mmm d yyyy, h:mm AMPM")

Exit Sub

MyError:
Call DispError(procname)
Exit Sub

End Sub
How do I get the event name, procname, using an object instead of assigning procname manually? I want to eliminate procname altogether.

Thank you.
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 18:23
Joined
Sep 12, 2006
Messages
15,710
we discussed this recently, and came to the conclusion you can't get the sub/func name programmaticallym directly within Access.
 

bulrush

Registered User.
Local time
Today, 13:23
Joined
Sep 1, 2009
Messages
209
Thank you.
 

boblarson

Smeghead
Local time
Today, 10:23
Joined
Jan 12, 2001
Messages
32,059
Actually there has to be a way to get the proc name but I have no idea how its done. If you get MZ Tools, you can set up an Error Handler template and it does include the proc name in there. So you can easily, with the click of a button, add the error handler and it will take care of getting the name.

So, if they can do it, it must be possible (even if it is just finding where the cursor is and going back to the sub or function header), eh Dave?
 

spikepl

Eledittingent Beliped
Local time
Today, 19:23
Joined
Nov 3, 2010
Messages
6,142
IN A2007 there is a button to show the stack, so surely there ought to be a way to extract that info?
 

Banana

split with a cherry atop.
Local time
Today, 10:23
Joined
Sep 1, 2005
Messages
6,318
Wayne also exposes this sort of thing with his vbWatchDog product (a commerical addin).
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 18:23
Joined
Sep 12, 2006
Messages
15,710
yes, i think its this stuff that Wayne refers to - that must contain the details about the event names etc etc. But it needs specialised knowledge to get at it.


form Wayne Philips' site - EverythingAccess.com

Although compiled MDE and ACCDE files no longer contain the exact source code from the original file, they do contain a lot of extra compiler data that when combined with the compiled code, can be used to very accurately recover the original source code.

....

Normal MDE files contain extra detailed information that we like to call compiler junk - this is redundant information about variable names, data types, constants and UDTs that are no longer needed in a fully compiled MDE file.
 

bulrush

Registered User.
Local time
Today, 13:23
Joined
Sep 1, 2009
Messages
209
I was looking at how to do it using vanilla Access with no add-ins. But thanks.
 

Users who are viewing this thread

Top Bottom