Go to a specific line number in code window (1 Viewer)

sxschech

Registered User.
Local time
Today, 11:02
Joined
Mar 2, 2010
Messages
791
Was looking for how to find and go to a line number in the code window since the information of the line and col is visible. While not as straight forward as Ctrl+F, found this code snippet.

https://social.msdn.microsoft.com/F...er-in-a-module-in-the-vba-editor?forum=isvvba
Code:
'---------------------------------------------------------------------------------------
' Method : Jumper
' Author : Blackhawk
' Author : [url]http://stackoverflow.com/questions/32381879/how-to-jump-to-line-number-in-vba-editor[/url]
' Date   : 9/3/2015
' Purpose: Jump to a line number in the VBE. A line in the code module or class you have open in
' the current code pane. Usage: Type Jumper 64 in the immediate window and hit enter to be taken
' to line 64. If that line is already in view, this does nothing, but if it's off the screen, it
' will automatically be scrolled to the center of the screen
' Remember to Trust access to the VBA project object model
' Keywords: jump to line, go to line
'---------------------------------------------------------------------------------------
Public Sub Jumper(line As Long)
    Application.VBE.ActiveCodePane.SetSelection line, 1, line, 1
End Sub
 

Gasman

Enthusiastic Amateur
Local time
Today, 18:02
Joined
Sep 21, 2011
Messages
14,046
I do not use line numbers in Access?, ever.

In fact I do not even know how to switch them on:D, and for some strange reason I do not like seeing them, so remove them when I have copied code that has them, :D
 
Last edited:

Micron

AWF VIP
Local time
Today, 14:02
Joined
Oct 20, 2018
Messages
3,476
I'm with you - but maybe we're missing out on something? IIRC, in BASIC an error message was always accompanied with a line number so it made sense.
 

isladogs

MVP / VIP
Local time
Today, 18:02
Joined
Jan 14, 2017
Messages
18,186
Line numbers can be added using utilities like VBE Tools.
I don't know of any way of adding these using the VBE interface itself

Line numbers are extremely useful when trying to pin down errors in code.
Otherwise I also prefer to remove them.

As for the jumper code (not yet tested), it could be useful but only if you know roughly where you want to go based on line number in a lengthy procedure.
You could add your own function based on that which prompts the user for a line number and assign an autokeys shortcut to run it e.g. Ctrl+Shift+N.

However, is it really more useful than using the Find feature for selected text on the current procedure in the VBE?
 

sxschech

Registered User.
Local time
Today, 11:02
Joined
Mar 2, 2010
Messages
791
Regarding posts #2 and 3...to be clear, wasn't referring to actual line numbers in the code, I don't use those either. Was referring to the line number indicator up on the ribbon. (see screenshot) Reason had a need to locate a line number was I had been testing some code variations and after got the results, wanted to be sure only the working code was saved and not the other things I tried. I took note of the section where I wanted to insert the new code and thought, it would be quicker to get to it after closing without saving and reopening Access by locating line x than having to scroll down to the spot or remembering a phrase in the general area.
 

Attachments

  • LineNoScreenShot.PNG
    LineNoScreenShot.PNG
    5.6 KB · Views: 164

Users who are viewing this thread

Top Bottom