Link to home
Start Free TrialLog in
Avatar of Phil
PhilFlag for United States of America

asked on

How can I pass an argument to a function called by the switchboard "run code" option?

I'm trying to streamline code by using just one function with arguments that I call from the Microsoft Access 2010 switchboard. I get an error and it appears that the "run code" option doesn't understand arguments.  Thanks!!
Avatar of Jeffrey Coachman
Jeffrey Coachman
Flag of United States of America image

I rarely use those Macro commands, so there may now be a way to pass arguments.

I would just use VBA Functions, where augments are part of the syntax.

Function CalcTotal(Quant as long, Price As Currency) as Currency
    CalcTotal=Quant*Price
End Function

...and you call it like this:
CalcTotal(me.txtQuant,me.txtPrice)

But you may have to give us the full details of exactly what you are doing...

Lets see what others may post in case I am misunderstanding something here...
Avatar of Phil

ASKER

Thank you for the information. What you are suggesting is exactly what I'm trying. The issue is that I'm trying to call the function through the switchboard manager. In the "Switchboard Items" table I have the command item set to "8" which is supposed to run code. The Argument field I have set to the function name "Open_Orders_Regular(me!txtOrderType)".

The Switchboard functionality will not let me send the paramater "me!txtOrderType".  It works fine without trying to send a paramater.
ASKER CERTIFIED SOLUTION
Avatar of PatHartman
PatHartman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Phil

ASKER

That's what I needed, thank you very much!