Running a Sub from Switchboard

rokuk

Registered User.
Local time
Today, 05:06
Joined
Dec 11, 2007
Messages
24
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 database 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 VBA code - not all of it, but I think this is all that will be involved. runDeletions() is located in its own module "Module3":

The Sub:
Code:
Public Sub runDeletions() 
     
    MsgBox "testing - runDeletions ran successfully" 
     
End Sub


This is the code in the switchboard form that deals with the arguments taken - and that will call the above function. Code within Private Function HandleButtonClick(intBtn As Integer):

Code:
 '...have the argument set to 8...
Const conCmdRunCode = 8 
 
 '... so this Case will run:
Case conCmdRunCode 
' optional, just tells me the value of the argument being used
'    MsgBox rs![Argument] 
'actually is what tries to call the Sub
    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: Module3.runDeletions()


I'm pretty sure my Argument is wrong. I've tried a few things but can't figure it out. What could I use as my Argument so my sub runDeletions in my module Module3 will run when this button is clicked?


Thanks!

PS - I've also posted this question here: http://www.vbaexpress.com/forum/showthread.php?t=16611 and any differences in code are intentional, as I keep trying different things (but so far no luck)...
 
My advice... Ditch the Access Wizard switchboard and create you own (Access form).

I think this is just the Access design team showing off. (Or at least showing what can be done with access)


When you add a button, simply select [Event Prodedure], then in the code window put: Call RunDeletions



Dave
 
hey Dave

hey Dave,


ya, thanks for the advice. I actually did just that a second ago. It took me about 30 seconds, and I'm really PO'ed I wasted so much time trying to get this working with the damn "access switchboard." Just checking back to update that I'm giving up on this piece of junk.

Thanks for the encouragement = )
 

Users who are viewing this thread

Back
Top Bottom