Solved

RunCode - Module

Posted on 2013-05-17
7
345 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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
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

Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

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…
QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

707 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

15 Experts available now in Live!

Get 1:1 Help Now