473,397 Members | 1,974 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,397 software developers and data experts.

How to navigate to specific procedure in a module or class module

Seth Schrock
2,965 Expert 2GB
Thanks to TheSmileyCoder's Access Crash Reporter, I get an email when an error occurs in my database. Part of the information in the email is the name of the module/class module and the name of the procedure in which the error occurred. I would like to be able to copy this information into a procedure that would take me to the specified procedure.

I already have the code in place to take the string "Error 52 has occured in procedure [AttachFile] in module [modTreeView] on line [60] on the following code:" and get the module and procedure name from that (using RegEx), but now I'm stuck on how to go to that place in my code. If the module is a regular module and not a form's class module, then I can use the DoCmd.OpenModule command, but it errors out saying that it can't find the module if I try to use it to open a form's class module.
Aug 12 '15 #1
4 1513
jforbes
1,107 Expert 1GB
Something like this might get you close...
Expand|Select|Wrap|Line Numbers
  1. Application.VBE.VBProjects(1).VBComponents("Form_FormName").CodeModule.CodePane.Show
or
Expand|Select|Wrap|Line Numbers
  1. Application.VBE.ActiveVBProject.VBComponents("Form_FormName").CodeModule.CodePane.Show
Aug 12 '15 #2
Seth Schrock
2,965 Expert 2GB
That opens the module perfectly, but now I need to go to the procedure. Any ideas?
Aug 12 '15 #3
Seth Schrock
2,965 Expert 2GB
Never mind. I found it.
Expand|Select|Wrap|Line Numbers
  1.     Dim lngStartLine As Long
  2.     With Application.VBE.ActiveVBProject.VBComponents(strModule).CodeModule
  3.         .codepane.Show
  4.         lngStartLine = .ProcStartLine(strProcedure, vbext_pk_Proc)
  5.         .codepane.SetSelection lngStartLine, 1, lngStartLine, 1
  6.     End With
Aug 12 '15 #4
jforbes
1,107 Expert 1GB
That is pretty neat.
Aug 12 '15 #5

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

Similar topics

42
by: WindAndWaves | last post by:
Dear All Can you tell me why you use a class module??? Thank you Nicolaas ---
2
by: windandwaves | last post by:
Hi Gurus I have a module with a bunch of functions that tell me everything about a table (e.g. the number of children, whether it exists, the table description, etc..., data-entry quality,...
4
by: Brad Parks | last post by:
Are there any performance or memory-usage benefits of placing public functions and subroutines in a Class Module rather than a standard module?
17
by: chris.atlee | last post by:
Hi there, I haven't seen this topic pop up in a while, so I thought I'd raise it again... What is the status of the path module/class PEP? Did somebody start writing one, or did it die? I...
2
by: ApexData | last post by:
Hello I'm sure the solution is simple and probably has something to do with the VB Editor. I want to create an EventProcedure link to an already created procedure that exists in my Form...
6
by: JonathanOrlev | last post by:
Hello everyone, I have a newbe question: In Access (2003) VBA, what is the difference between a Module and a Class Module in the VBA development environment? If I remember correctly, new...
7
by: Brad Pears | last post by:
I am developing a simple error message class and would like the be able to generate as part of the message the curent class/module/form and function or sub that the error was generated in without...
0
ADezii
by: ADezii | last post by:
The motivation for this Tip was a question asked by one of our Resident Experts, FishVal. The question was: How to Declare Default Method/Property in a Class Module? My response to the question was...
8
by: RojK | last post by:
Hi, I have a userform which has some command buttons and multiple listboxes in VBA. I have a class module which handles events on the form, and a code in the form's initialization section which...
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.