F5 and F8 not working in VBA (1 Viewer)

GregAcc

New member
Local time
Today, 17:27
Joined
Jun 25, 2020
Messages
13
Hi, I have a very basic problem, but I really don't how to run code with the f5 or f8 key. When I press f5 I could only get Macros dialog. Pressing the green Play button above makes no different??
Thanks
 

Gasman

Enthusiastic Amateur
Local time
Today, 16:27
Joined
Sep 21, 2011
Messages
14,223
You do need to be in the correct Sub to use those keys.
Have you used Alt+F11 to get into the VB window first?
 

GregAcc

New member
Local time
Today, 17:27
Joined
Jun 25, 2020
Messages
13
Yes I am in VB window with Alt F11. Could you try it on attached database?
 

Attachments

  • database.zip
    128.7 KB · Views: 135

Gasman

Enthusiastic Amateur
Local time
Today, 16:27
Joined
Sep 21, 2011
Messages
14,223
Sorry, I can't. I only have 2007 and it comes up as unrecognized format.
 

Isaac

Lifelong Learner
Local time
Today, 08:27
Joined
Mar 14, 2017
Messages
8,774
You're talking about in Excel, right? If so this should be in the Excel forum.

Anyway, is there any chance that you're trying to press F5 while your cursor is inside a procedure that takes parameters ?
Or, any function ?

Doing either of those will pop up the Macros dialogue, rather than running anything.
 

Gasman

Enthusiastic Amateur
Local time
Today, 16:27
Joined
Sep 21, 2011
Messages
14,223
You're talking about in Excel, right? If so this should be in the Excel forum.

Anyway, is there any chance that you're trying to press F5 while your cursor is inside a procedure that takes parameters ?
Or, any function ?

Doing either of those will pop up the Macros dialogue, rather than running anything.
The o/p uploaded a DB ? :unsure:
 

Isaac

Lifelong Learner
Local time
Today, 08:27
Joined
Mar 14, 2017
Messages
8,774
The o/p uploaded a DB ? :unsure:
My mistake - I stand corrected. For some reason, I seem to often not see the visual cue on uploaded zip files to posts. Something about my color scheme maybe they just don't stand out.

Regardless, the rest of my post still stands, and applies here. The reason for the Macros dialogue box happens when your cursor is within a procedure that simply CAN'T be "run" just so.

An example would be the database OP posted which I just looked at - there aren't any non-form or non-control-related independent procedures. All there are are form class modules. The answer is OP simply cannot just "run" those subs. They are wired to events.

I've created a real independent procedure (the first one in the database that I can find anyway), called "Test". Put your cursor there and press F5, it works fine. Attached here.

Putting your cursor in procedures that are wired to form or control events (_click, _load, etc), and pressing F5 won't do anything other than display that box.
 

Attachments

  • database.accdb
    1.1 MB · Views: 150

Gasman

Enthusiastic Amateur
Local time
Today, 16:27
Joined
Sep 21, 2011
Messages
14,223
Thank you Isaac, I could not open the DB due to my version of Access.
 

GregAcc

New member
Local time
Today, 17:27
Joined
Jun 25, 2020
Messages
13
Thank you, Isaac.
So does that mean I can't test the code if it's associated with a form or if it has characters like (_click, _load, etc),?
Is there any other way to test code something like it is shown here in that video?
 

Gasman

Enthusiastic Amateur
Local time
Today, 16:27
Joined
Sep 21, 2011
Messages
14,223
Thank you, Isaac.
So does that mean I can't test the code if it's associated with a form or if it has characters like (_click, _load, etc),?
Is there any other way to test code something like it is shown here in that video?
You would need to set a breakpoint in one of the events then use the form?
 

GregAcc

New member
Local time
Today, 17:27
Joined
Jun 25, 2020
Messages
13
I figured out how to handle it. As you already said, first I need to put breakpoint and then trigger the event in a form that make a code process. So after that I just need to press button in a form and then can I continue with F8 key in VBA window.
 

LegacyFDP

New member
Local time
Today, 16:27
Joined
Feb 20, 2020
Messages
1
Hi, I have a very basic problem, but I really don't how to run code with the f5 or f8 key. When I press f5 I could only get Macros dialog. Pressing the green Play button above makes no different??
Thanks
Try View/Toolbars/Debug and click on the green arrow for F5 and the icon on the right of the hand for F8. Not as easy as F5 or F8 but it works.
 

Users who are viewing this thread

Top Bottom