473,225 Members | 1,298 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,225 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 1501
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
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
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

by: WindAndWaves | last post by:
Dear All Can you tell me why you use a class module??? Thank you Nicolaas ---
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,...
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?
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...
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...
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...
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...
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...
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...
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

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.