?
Solved

RunCode - Module

Posted on 2013-05-17
7
Medium Priority
?
401 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 120

Assisted Solution

by:Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1) earned 668 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 664 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 58

Accepted Solution

by:
Jim Dettman (Microsoft MVP/ EE MVE) earned 668 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
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.

 
LVL 58
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

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Question has a verified solution.

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

This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Suggested Courses

752 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