By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,707 Members | 965 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,707 IT Pros & Developers. It's quick & easy.

Runcode recieving error 2425

P: 20
In MS Access 2010,I am trying to write some code to a module that I can then use RunCode to run from an AutoExec macro. I have written the code that I think should go in the module and get no errors when I debug/compile it. But when I try to use Runcode and run the macro I get error message 2425 which states "the expression you entered has a function name the Microsoft Access can't find." I checked to make sure that the name of the function called by RunCode was correct. So now, I can't tell what the problem is. Here is my code:
Expand|Select|Wrap|Line Numbers
  1. Function OpenExcelFromAccess()
  2.     Dim MyXL As Object
  3.  
  4.     Set MyXL = CreateObject("Excel.Application")
  5.     With MyXL
  6.     .Application.Visible = True
  7.     .Workbooks.Open "S:\DateCodes.xlxs"
  8.     End With
  9.  
  10. End Function
Aug 26 '19 #1
Share this Question
Share on Google+
4 Replies


NeoPa
Expert Mod 15k+
P: 31,754
Is it in a Standard module?
If not then either move it to one or qualify any references to it explicitly.

Is it defined as Public?
Clearly not in your code. Does it default to Public if not specified? Is it visible as an option from the user interface Run Macro box (Database Tools | Run Macro)? If not then it isn't available and that is very likely because it's either not Public or not in a Standard Module.
Aug 26 '19 #2

P: 1
I have same issue, good hint what do you mean by standard
module. Cant see why my module wouldn t be standard.
Thanks
May 4 '20 #3

NeoPa
Expert Mod 15k+
P: 31,754
I don't generally respond at all where third parties put addenda into threads but I will do so for this one as a strictly one-off exception (IE. If you need further help you will need to post in a separate thread or see your posts removed). Your question could prove generally helpful.

In the VBIDE (Visual Basic Integrated Development Environment) you can generally see the Project Explorer which allows you to see the Objects (Forms & Reports), the Class Modules & the Standard Modules. If you right-click and select Insert then Module it will create a new Standard Module for you.

There are essentially three types of module :
  1. Those associated with Objects (Forms or Reports).
  2. Class Modules.
  3. Standard Modules.
Only #3 (Standard Module) procedures, variables and constants can be referenced from anywhere in the project without qualification. The others are all Class Modules of one type or another and require qualification in any reference either from the Class or the Instance.
May 5 '20 #4

ADezii
Expert 5K+
P: 8,692
In the Function Name Argument of your Macro, be sure to include the opening and closing parenthesis, as in:
Expand|Select|Wrap|Line Numbers
  1. OpenExcelFromAccess()
May 5 '20 #5

Post your reply

Sign in to post your reply or Sign up for a free account.