PDA

View Full Version : Run Custom Sub from Switchboard Item



rokuk
12-10-2007, 08:02 PM
Hi there!

I am having a fair amount of trouble figuring this out, and I was hoping someone might know what I was doing wrong. Someone set up a switchboard (I think using the Switchboard wizard) in this Access DB. I've since taken on the project of automating a process and I want to use a switchboard item so it's a one-click, otherwise mostly automatic process. I have added the switchboard item, and when I click on it I get a msgbox displaying with my test text, so I think that is set up OK.


Right now, I am trying to have a click on the button launch a custom sub (that I still have to write). Right now all I have in that sub is another call to a Msgbox with other testing text.


Following is the relevant code - not all of it, but I think this is all that will be involved. It is all located in the code for the switchboard form right now. I don't know if this is OK, but I really don't know how to reassign everything if I move it to another place, like a module, but I imagine it should work even if it is messy, so...:

The Sub:
Private Sub runDeletions()

MsgBox "YAAAAAY"

End Sub

Code within Private Function HandleButtonClick(intBtn As Integer):

'... assumed this would be the proper "command" to use
Const conCmdRunCode = 8

'... have this display the value being used in the "argument" field before trying to "run" the sub
' Run code.
Case conCmdRunCode
MsgBox rs![Argument]
Application.Run rs![Argument]

I've found the Switchboard Items table, and added in the following record. It has
SwitchboardID as: 3 (this button is on its own page)
ItemNumber as: 1
Itemtext as: Run Pending Deletions
Command as: 8
Argument as: runDeletions()


I have also tried the Argument as /"runDeletions()/" and runDeletions and /"runDeletions/"


I am almost positive my trouble lies somewhere in these few things. I suspect I have the Argument field entered wrong. But what can I do to run this sub?!


Thank you for any suggestions you may have!

rokuk
12-11-2007, 01:03 PM
I've wasted too much time on this, and after reading how horrible the "Access switchboard" is for doing anything beyond the basic I just made my own userform and took 30 seconds to get this working.

I just wanted to check back and say: no, I haven't found a solution to this other than forgetting to use the overly complicated Access switchboard and just doing it by creating my own custom forms. I'd suggest anyone else to just do the same.


Thanks

:beerchug:

carlmack
12-11-2007, 01:36 PM
LOL. I would agree. Constant 8 sounds ok. You would need the argument to be just the name of the sub. The sub would need to be Public and in a new (standard) module.