Solved: Macro Require Function Code

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

mariaa33

Thread Starter
Joined
Aug 7, 2008
Messages
164
I created a macro to runcode for a sub procedure and included that as a button on the switchboard. It executes just fine from VBA but when I try to run the macro, the help says it has to use a Function to call the subprocedure. I do not know how to write a Function to call a subprocedure (ExportWeeklyChron). Can anybody help?
 
Joined
Apr 7, 2007
Messages
439
I'm guessing this is Access.

Just type your sub's name where it says Function - it works for me. I just wrote a simple

Code:
Sub aTest ()
[INDENT]MsgBox "Hello World"[/INDENT]
End Sub
And where the switchboard item, under Command = Run Code, Function Name = aTest; and this works.

If you've tried this and it doesn't work, then can you give some more information, what options are you selecting on the switchboard etc.
 

mariaa33

Thread Starter
Joined
Aug 7, 2008
Messages
164
I did the exact code that you have above and I get "There was an error executing the command" from the switchboard. If I have the above as a macro to run code, I get "The expression you entered has a function name that Microsoft Access can't find." I am using Access 2003.
 

mariaa33

Thread Starter
Joined
Aug 7, 2008
Messages
164
Nevermind, I changed the macro to just run the query and output to excel file with the Output To. Boy, much simplier!!
 
Joined
Sep 4, 2003
Messages
4,912
The example above shows a sub procedure NOT a function.

A function has the following syntax
Code:
Public Function MyFunction()
'Your Code
End Function
Regards,
Rollin
 
Joined
Apr 7, 2007
Messages
439
The example above shows a sub procedure NOT a function.

A function has the following syntax
Code:
Public Function MyFunction()
'Your Code
End Function
Regards,
Rollin
Yes - I know this, however, it works.

I did the exact code that you have above and I get "There was an error executing the command" from the switchboard. If I have the above as a macro to run code, I get "The expression you entered has a function name that Microsoft Access can't find." I am using Access 2003.
This is very odd, as I ran it both at Home and at Work, both Access 2003, and both work perfectly.
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Members online

Top