run VBA code in Macro (1 Viewer)

Dylan Snyder

Registered User.
Local time
Today, 14:35
Joined
Dec 31, 2007
Messages
89
Is it possible to run VBA code within a macro?
What i want to do is run one macro for certain days of the week and another macro for other days of the week. I could just stick the code in the button on the switchboard but I could see an overzealous user changing the switchboard and then the code is gone. I like the idea of the code within the macro itself so someone not familiar with VBA could alter it.

I tried putting something like
If Me.Today = "Monday" Then
DoCmd.RunMacro "Macro2"
ElseIf Me.Today = "Thursday" Then DoCmd.RunMacro "Macro2"
Else: DoCmd.RunMacro "Macro3"
End If

In the RunCode action of the Macro with no success.
i'm sure there is an easy fix, but I'm not seeing it. Any thoughts?
 

Dylan Snyder

Registered User.
Local time
Today, 14:35
Joined
Dec 31, 2007
Messages
89
oops, Me.Today was the code I put originally on the switchboard (Format(Date(), "dddd") =Me.Today default value). I guess that won't work in this situation, though.
 
M

Mike375

Guest
Make the code as a module and use the RunCode action in the macro and just put the function name with the brackets

RunCode

Function Name ExtraNote()
 

Dylan Snyder

Registered User.
Local time
Today, 14:35
Joined
Dec 31, 2007
Messages
89
Thanks. Never used Modules. I will investigate. Thanks again.
 

Users who are viewing this thread

Top Bottom