Solved

RunCode - Module

Posted on 2013-05-17
7
385 Views
Last Modified: 2013-05-17
Hi this is my first time using modules and I would like to setup a Macro to execute/run code for the modutle, however I receive error 2425 - The expression you entered has a function name that Microsoft Access can't find.  Not sure what I am doing wrong.  The function that I am trying to call is a Public Function named ClearTable().
0
Comment
Question by:jmac001
7 Comments
 
LVL 120

Assisted Solution

by:Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1) earned 167 total points
ID: 39175175
where did you place the function

 Public Function ClearTable()., it should be in a regular module

what name did you give for the Module?  i hope it is not ClearTable

if you did, change the name of the module to modClearTable
0
 
LVL 61

Assisted Solution

by:mbizup
mbizup earned 166 total points
ID: 39175180
Make sure that you have a function named  ClearTable in a code module, and also ensure that you have saved the module that contains this function with a name that is anything other than "ClearTable".

A good name for your module might be "modMyFunctions"
0
 
LVL 57

Accepted Solution

by:
Jim Dettman (Microsoft MVP/ EE MVE) earned 167 total points
ID: 39175183
ClearTable() must be in a standard module (not a form, report, or class module), you cannot have a module with the same name, and it must be a function if your calling it from a macro.

Also make sure your in a compiled state (in the VBA Editor, click debug/compile)

Jim.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 57
ID: 39175190
Boy are the sharks circling or what<g>?

Everyone must have time on their hands today...

Jim.
0
 
LVL 10

Expert Comment

by:Anthony Berenguel
ID: 39175191
FYI: Modules are containers for subprocedures and functions. As long as you declare the subs and functions as public you should be able to call those subs and functions from anywhere in your code. In this sense, modules are very cool because you can write a sub or function that can be used by any form or report in your database application (Whereas code stored a form will only be available to that specific form).

You might have already known that stuff but I thought I would provide the info in case you didn't.

Can you provide the line of code that is causing the error? I would like to see how you're calling the function ClearTable(). Also, have you confirmed ClearTable() exists? Perhaps there is a spelling issue between the call statement and the actual function name.
0
 
LVL 61

Expert Comment

by:mbizup
ID: 39175198
Jim - Just killing what little time I've got at the moment :-)

Heading out of town for the weekend.
0
 

Author Comment

by:jmac001
ID: 39175221
Thank you all, the problem was that the module was named ClearTable.  Renamed modClearTable and it is now working
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question