VBA SUB not found when calling from a marco

GregoryWest

Registered User.
Local time
Today, 15:18
Joined
Apr 13, 2014
Messages
161
I have a temp macro that has one step: Run Code : MakeExp


Inside my Module1 I have the following:


Public Sub MakeExp()

Dim rs_in As DAO.Recordset
Dim rs_out As DAO.Recordset
Dim strSql_in As String
Dim strSql_out As String
Dim ExpName As String 'Path and name of text file

---A ton more lines
sline = sline & slegal & Chr(34)
rs_in.MoveNext
Loop
Print #ExpNumber, sline
Close #ExpNumber
Close rs_in
End Sub

But when I run the macro I get the following error:
MicroSoft Access can not find the name 'MakeExp' you entered in the expression


Can anyone shed light on why this might not be working? Did I forget about telling Access the code is in Module1 (dont think I need to do that.....)
 
Make it a Function instead of Sub.

But why use macro?
 
I do get the same error message, with a function. The reason for a macro is just to test. Been having a few little problems, and thought this should work for sure.... but it doesn't
 
Works for me. Need to know your macro code.
 
As already stated, you can call functions in macros but not subs
Use Run Code in the macro command.
Intellisense will kick in to allow autocomplete to run.
Make sure you have () at the end of the function name

Testing is much easier using vba.
 
The macro is : RunCode, with MakeExp in the function name field.


I have been wondering, if there could be some sort of corruption in the avvdb. If so what would be the best way to test/fix?
 
As mentioned it should be MakeExp()

If you use the builder, that is what it will place in for the Argument
 
WOW do I feel stupid. Been looking at that code for a few days now, did not even notice the lack of the (). Sigh, getting too old for this.



As mentioned it should be MakeExp()

If you use the builder, that is what it will place in for the Argument
 
If you use the builder, that is what it will place in for the Argument

Actually if you use intellisense, it will only add the (
You need to add the ) yourself.
I assume the reason is that you may need to specify a function argument before adding the )
 
Care to make it Solved, by Thread Tools in the post header.?
 

Users who are viewing this thread

Back
Top Bottom