Runtime error calls for macros that are Module subs

H

Hunter57

This is really weird. All of my VBA subs run fine except for from the
VBA Editor Window (they even work in the Immediate Window). But
whenever I try to use the VBA Editor Window to run any sub in ANY
Access DB from in form module or any module I get an error--even with
simple subs like this:

Private Sub myTest(Cancel As Integer)
MsgBox "There is no data for this report. Canceling report..."
End Sub

This is what happens: A Macro Dialog box opens and lists Subs from
Modules are listed in the Macro Dialog box.

It does the same thing in databases that I download.

I am beginning to think I may need to reinstall or repair Access.

Can anybody help?

Pat
 
S

Stefan Hoffmann

hi,
Private Sub myTest(Cancel As Integer)
MsgBox "There is no data for this report. Canceling report..."
End Sub

This is what happens: A Macro Dialog box opens and lists Subs from
Modules are listed in the Macro Dialog box.
I am beginning to think I may need to reinstall or repair Access.

Can anybody help?
That is the default. Only Public Subs can be executed directly by
pressing F5.


mfG
--> stefan <--
 
M

Matthias Klaey

Hunter57 said:
This is really weird. All of my VBA subs run fine except for from the
VBA Editor Window (they even work in the Immediate Window). But
whenever I try to use the VBA Editor Window to run any sub in ANY
Access DB from in form module or any module I get an error--even with
simple subs like this:

Private Sub myTest(Cancel As Integer)
MsgBox "There is no data for this report. Canceling report..."
End Sub

This is what happens: A Macro Dialog box opens and lists Subs from
Modules are listed in the Macro Dialog box.

It does the same thing in databases that I download.

I am beginning to think I may need to reinstall or repair Access.

Can anybody help?

Pat

You need to position the cursor in the Editor Window *within* the Sub
that you want to run. If the cursor is in the General Section (before
the first procedure) or at the end (after the last procedure) or
between procedures, the Macro dialog box pops up just as you describe,
since Access cannot know which procedure you want to run.

HTH
Matthias Kläy
 
M

Matthias Klaey

Stefan Hoffmann said:
hi,

That is the default. Only Public Subs can be executed directly by
pressing F5.


mfG
--> stefan <--

To be a little more precise:
You can run private or public procedures (subs or functions) with F5,
but only if they do not have any arguments.

Matthias Kläy
 
H

Hunter57

hi,



pressing F5.

mfG
--> stefan <--

I have been working with Access steadily for several months, reading
books, reading the group threads, and I guess I just missed that simple
fact. Thanks for the education.

Humbly yours,

Hunter57
 
H

Hunter57

that you want to run. If the cursor is in the General Section (before
the first procedure) or at the end (after the last procedure) or
between procedures, the Macro dialog box pops up just as you describe,
since Access cannot know which procedure you want to run.

HTH
Matthias Kläy
--www.kcc.ch- Hide quoted text -- Show quoted text -

Thanks for your tip about not running a Public Sub or Function with
arguments. I appreciate your patience with a newbie.

Pat
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top