Solved

RunCode - Module

Posted on 2013-05-17
7
354 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 119

Assisted Solution

by:Rey Obrero
Rey Obrero 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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Suggested Solutions

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

919 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now