473,385 Members | 1,402 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Dynamic reference to current procedure

Is there a way to dynamically refer to the name of the current procedure?
I'd like to add a dynamic reference to the current procedure in my logging procedure.

I've googled around and found nothing (just another guy asking the same question on the utteraccess board, but with no answer).

TIA for any help!
Apr 1 '08 #1
5 3819
NeoPa
32,556 Expert Mod 16PB
Interesting question.

I had a dig around but couldn't find anything that looked remotely relevant I'm afraid.

PS. Please let us know if you find anything.
Apr 2 '08 #2
Scott Price
1,384 Expert 1GB
Well... There is no direct way to do this. However, there is an indirect way that might work. Assuming you are using this for error handling/logging:
Expand|Select|Wrap|Line Numbers
  1. 1:
  2.  
  3. Dim cllProc As String
  4.  
  5. cllProc = Me.Module.Procofline(Erl, vbext_pk_Proc)
You might need to add a reference to the VBA Extensibility library. This would be Microsoft Visual Basic for Applications Extensibility 5.3 (or newer version number).

This will return a string with the name of the current procedure that throws an error. The Procofline property pertains to the VBIDE.Module or Access.Module object, takes two arguments: a valid line number in the procedure, and the type of procedure... The Erl() function is the undocumented Error Line function which has a few bugs, hence the 1: label placed above the variable declaration. The Erl() function isn't too specific at times, when an error does occur, it chooses the first available line label ABOVE where the error occurred, means that if there are no line labels, it returns 0, which can affect our ProcOfLine property.

Have I made this clear as mud, or is it somewhat understandable? :-)

Regards,
Scott

p.s. Unfortunately VBA doesn't provide what VB.NET does: System.Reflection.MethodBase.GetCurrentMethod.Name ()
Apr 2 '08 #3
I'll give it a shot! I'm trying to log activity to a file and it sure would help.

Thanks!
Apr 2 '08 #4
NeoPa
32,556 Expert Mod 16PB
Scott's answer may be the most help. The best I could find was a reference to the name of the current module :
Expand|Select|Wrap|Line Numbers
  1. Me.Module.Name
...This only gives the same name as the object though (== Me.Name).
Apr 2 '08 #5
Scott Price
1,384 Expert 1GB
As an alternative to using the Erl function you could simply create a variable tuned to hold a line number within the current procedure, then refer to this variable in the Procofline() property, this is a little more suspect, though, as any changes in the code (i.e. adding a procedure above) could potentially invalidate this variable.

Regards,
Scott
Apr 2 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Frederic Jolliton | last post by:
Hi, My problem is rather complex. I will try to explain it clearly (I hope !) Sorry for my poor english. I'm tracking change of state for entities (something than can be monitored.) The...
1
by: Todd Peterson | last post by:
I'm a newbie to DB2 and am trying to figure out how to write a stored procedure, using dynamic SQL statements to return a result set. I believe the majority of the hurdles I have been facing might...
1
by: Nathan Bloomfield | last post by:
Does anyone know if there is any documentation which relates to Access2k + ? or can anyone help adjust the code? I am having trouble converting the DAO references. TITLE :INF: How to...
3
by: CAD Fiend | last post by:
Hello, Well, after an initial review of my database by my client, they have completely changed their minds about how they want their form. As a result, I'm having to re-think the whole process....
3
by: Leo J. Hart IV | last post by:
OK, here's another question for the experts: I am building a multi-step (3 steps actually) form using a panel for each step and hiding/displaying the appropriate panel/panels depending on which...
3
by: giftron | last post by:
MS Access 2000- I have a table with 200 fields named F001 through F200 and a form to collect data for those fields. I need to execute an event procedure On Exit to do a conversion ie. ...
5
by: SQLJunkie | last post by:
I have a small SQL script that rotates through all databases on the server and executes a Stored Procedure in each of them. Here are the steps: 1: The first step is to get name of databases in to...
7
by: bprocopio | last post by:
Please help. I'm stumped. I need to create a dynamic variable in a procedure that will be used to update a variable of the same name in a table. i.e. the name in tblAnalysisScores are...
26
by: Aaron \Castironpi\ Brady | last post by:
Hello all, To me, this is a somewhat unintuitive behavior. I want to discuss the parts of it I don't understand. .... f= lambda: n .... 9 9
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.