Standard Module Creation

J

JCIrish

This is from a beginning user of VBA in Access 2007. I go to
Create>Module>insert procedure and then write a simple sub. Then I save it
and give it a name. The named module appears in the navigation pane. However,
when I try to run it I get a dialog box that asks me to name a macro. I don't
understand this. What am I doing wrong?(I've enabled content in the security
bar). Please help. I'm in a rut at the very beginning of the learning process
 
J

John Spencer

Did you name the module something other than the name of the sub. Module
names cannot be the same as the name of any function or sub. I usually name
all my modules with MOD at the beginning - mod_StringFunctions,
mod_queryFunctions, etc.
John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 
J

JCIrish

Thanks for the response, John. the module does have a different name from the
sub. In this case it is named modBusinessLogic. The funny thing is that this
glitch is something new. On previous occasions I have used this procedure
with no problems, no dialog box asking me to name a macro. Any other
suggetions?

JCIrish
 
D

Dirk Goldgar

JCIrish said:
This is from a beginning user of VBA in Access 2007. I go to
Create>Module>insert procedure and then write a simple sub. Then I save it
and give it a name. The named module appears in the navigation pane.
However,
when I try to run it I get a dialog box that asks me to name a macro. I
don't
understand this. What am I doing wrong?(I've enabled content in the
security
bar). Please help. I'm in a rut at the very beginning of the learning
process


1. Are you trying to run the module, when you you should be trying to run
the procedure?

2. If your procedure takes any arguments, you can't just run it -- you have
to invoke it in a way that passes the necessary arguments; from the
Immediate window, for example. If you just click the Run button, it will
prompt you for a macro the way you describe.
 
J

John Spencer

Not really. I have not yet had the occasion to use Access 2007 much. All my
customers are using Access 97 to Access 2003. None have upgraded to 2007 and
most don't plan to for a while.

So I've only been dabbling with Access 2007 and have not seen the problem you
are having. If you don't get any more feedback, may I suggest you repost your
problem.

To be immodest, my name on a reply may cause someone with more experience in
to believe that I had the solution. I really should not have replied since my
experience with 2007 is limited.


John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
 
J

JCIrish

Thanks, again John. I appreciate your respnse

John Spencer said:
Not really. I have not yet had the occasion to use Access 2007 much. All my
customers are using Access 97 to Access 2003. None have upgraded to 2007 and
most don't plan to for a while.

So I've only been dabbling with Access 2007 and have not seen the problem you
are having. If you don't get any more feedback, may I suggest you repost your
problem.

To be immodest, my name on a reply may cause someone with more experience in
to believe that I had the solution. I really should not have replied since my
experience with 2007 is limited.


John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
 
J

JCIrish

Thank you, thank you, Dirk. That was indeed my problem. Thanks for helping
this rookie.

JCIrish
 
P

Pete D.

Explain what you are doing to try and run it. Try running it from the
intermediate window something like

? IsLoaded("Form_Switchboard")

or whatever your sub is.
 
P

Pete D.

Okay, I duplicated this behavior, don't know if this is you problem or not
as I didn't see your code. If your sub requires a parameter and you don't
provide it correctly the macro select box will pop up requesting you to
select a macro to run. Run it from intermediate window and provide it the
correct parameter. You can test this with putting your cursor on the first
line of below complile and select run. First one will prompt you for macro,
second one will not. But if you run first one from intemediate window and
provide the text first one will also run successfully.

'cause macro prompt
Private Sub SaySomething(TxtBox As String)
MsgBox ("something")
End Sub

'no macro prompt, just runs
Private Sub SaySomething()
MsgBox ("something")
End Sub
 

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