Solved

RunCode - Module

Posted on 2013-05-17
7
374 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
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 
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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

809 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