run VBA code in Macro

Dylan Snyder

Registered User.
Local time
Today, 15:21
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?
 
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.
 
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()
 

Users who are viewing this thread

Back
Top Bottom