Monday, April 25, 2005 4:23 PMI have a command button on a form to delete the current record. The corresponding subroutine is called Private Sub cmdDelete_Click(). I'm looking for a way to display "cmdDelete_Click" in an error message if an error is thrown. I want to have the the statment be the same for each subroutine I have so I don't have to hard code the name for each one. Is there a way to return the name of the current subroutine as I described? I found something like form.module.name but that wasn't it.
Monday, April 25, 2005 8:13 PMYou can pull that information out of the Exception object, here is a good example of doing just that:
Tuesday, April 26, 2005 1:54 PMThanks James. That link is dead at the moment. Do you have an example on hand?
Tuesday, April 26, 2005 3:42 PMI just checked and it should be working now:
If it doesnt work send me your email and I will email you the example code. (javery @~ no spam ~infozerk.com, remove the nospam part)
Saturday, July 23, 2005 3:43 AMHere's an example - which will display the Assembly and function name that the exception was thrown in.
Catch ex As Exception
dim sprocedurename as string
sprocedurename = ex.TargetSite.DeclaringType.Assembly.GetName().Name & ": " & ex.TargetSite.Name & "()"