Switchboard Question: Run Code

mrb783

Registered User.
Local time
Today, 11:47
Joined
Oct 28, 2008
Messages
40
Hello, I've been finagling with a form that has a single button that executes some code (which it does flawlessly now). Anyway, I want to execute said code from my switchboard rather than force someone to open a form and click a button. The function is a simple one that simply calls other functions to do some minor string cleanup within my database (no parameters needed).

I have moved the code to a Module (named "Cleanup") and the sub function that I would call is called "Clean_the_database". I can't, however, figure out how to make this call from the Switchboard manager. I basically took the button code, changed it to a Public sub and should be able to call it...but I can't figure out the syntax and apparently my googling skills are weak today.

Any ideas?
 
First, did you create it as a sub-routine or a function?
 
Here's what I'm attempting to call:

Code:
Public Sub Clean_the_database()

Dim SQL_Supervisor As String
Dim SQL_FCG As String
Dim SQL_Competencies As String
Dim SQL_RotationArea As String

SQL_Supervisor = "Line Manager/Supervisor CDSID(s)"
SQL_FCG = "Current and past FCG CDSID(s) in this rotation"
SQL_Competencies = "Core Competencies to be gained"
SQL_RotationArea = "UPDATE Carousel, RotationAreas SET Carousel.[Rotation Area] = RotationAreas.RotationAreaName WHERE (((Carousel.[Rotation Area])=RotationAreas.RotationArea))"

FixCDSIDs (SQL_Supervisor)
FixCDSIDs (SQL_FCG)
FixCompetencies (SQL_Competencies)
DoCmd.SetWarnings False
DoCmd.RunSQL (SQL_RotationArea)

MsgBox ("The database has been cleaned.")

End Sub
 
You just put Clean_the_database in your code. No parens or docmd type stuff, just:

Clean_the_database
 
It needs to be a function, and not a sub, for the RunCode item in the switchboard manager to find it.
 

Users who are viewing this thread

Back
Top Bottom