VBA Line by line !!! (1 Viewer)

ECEK

Registered User.
Local time
Today, 16:06
Joined
Dec 19, 2012
Messages
717
I have my OnTimer events

These are mainly queries.

What is the shortcut in vba to run each line of code within VBA?
 

isladogs

MVP / VIP
Local time
Today, 16:06
Joined
Jan 14, 2017
Messages
18,186
It depends on what you want to do.
Probably F8 for Step Into...
Have a look at the choices in the VBE Debug window

NOTE I'm not clear why you referred to the On Timer events
 

ECEK

Registered User.
Local time
Today, 16:06
Joined
Dec 19, 2012
Messages
717
I read that ontimer could cause an issue. I included it just in case.
I have tried selecting the beginning, end whole of the line of text and pressed F8....nothing
I have tried a blank line and pressed ctrl F8 (expecting the code to run upto the point of the curser....nothing other than a message to say that that "Line is not an executable statement"

what I'm looking to do is (for example) run the queries from the code as opposed to reading the code and manually running them.
 

Minty

AWF VIP
Local time
Today, 16:06
Joined
Jul 26, 2013
Messages
10,354
Put a breakpoint into your code (Click in the border to the left of your code and you'll get a big brown/reddy coloured blob.)

Execute your code normally and it will stop on the blob, then press F8 to step through it.
 

ECEK

Registered User.
Local time
Today, 16:06
Joined
Dec 19, 2012
Messages
717
How do I execute the code?
I'm being awfully dumb here....please bear with me !
 

isladogs

MVP / VIP
Local time
Today, 16:06
Joined
Jan 14, 2017
Messages
18,186
Run the code as you would normally do e.g. by clicking a button etc
 

Micron

AWF VIP
Local time
Today, 12:06
Joined
Oct 20, 2018
Messages
3,476
I think it's F5 to start code, F8 to step through. Not only does this sometimes depend on your pc/laptop (I must use fn+F8 keys) whether or not it works depends on factors I've never bothered to figure out. That is, sometimes a Run Macro dialog pops up.
In addition, if it's a procedure that requires parameters, simply pressing F5 won't work. Approach would be to call the procedure by typing its name and the parameters in the immediate window after putting a break point in the code. If you continue to have issues, maybe post the code so we can see what's involved.
 

CJ_London

Super Moderator
Staff member
Local time
Today, 16:06
Joined
Feb 19, 2013
Messages
16,553
you mention the ontimer event - a form event.

you can only start running code using ctrl-F8/F5 in a standard module - and that in a function or sub which does not have parameters.

In a class module (i.e. a form module) you need to start the code on a form/control event, use a breakpoint to pause the code, then F8/F5 to step through/continue.
 

Galaxiom

Super Moderator
Staff member
Local time
Tomorrow, 03:06
Joined
Jan 20, 2009
Messages
12,849
you can only start running code using ctrl-F8/F5 in a standard module - and that in a function or sub which does not have parameters.

In a class module (i.e. a form module) you need to start the code on a form/control event, use a breakpoint to pause the code, then F8/F5 to step through/continue.

I click the little green arrow button to Start. It is in the Standard Toolbar.

Step In Step Out, Step Over are also available.

Comment Block and Uncomment Block are really useful too.

All toolbars can be fully customised.
 

Users who are viewing this thread

Top Bottom