I am attempting to not duplicate a long Sub by passing a parameter from the "On Click" event of a command button.
The command button wizard created a sub called
"public Sub cmdRunReport_Click()" which has a lot of code which I do not want to duplicate for maintenance reasons.
Now I need to make two versions of the report, one for OPEN records and one DUE records and call these from two command buttons, one called "cmdOPEN" the other "cmdDue".
How can I have two command buttons call the same VB sub routine but pass a parameter?
For example
cmdRunReport_Click("Open")or
cmdRunReport_Click("Due")
If I paste either of the two examples above in the properties tab instead of [Event Procedure] Access just thinks I am attempting to run a macro.
I know how to pass parameters to Sub or Functions from within the VBA module but never in this particular way.
The command button wizard created a sub called
"public Sub cmdRunReport_Click()" which has a lot of code which I do not want to duplicate for maintenance reasons.
Now I need to make two versions of the report, one for OPEN records and one DUE records and call these from two command buttons, one called "cmdOPEN" the other "cmdDue".
How can I have two command buttons call the same VB sub routine but pass a parameter?
For example
cmdRunReport_Click("Open")or
cmdRunReport_Click("Due")
If I paste either of the two examples above in the properties tab instead of [Event Procedure] Access just thinks I am attempting to run a macro.
I know how to pass parameters to Sub or Functions from within the VBA module but never in this particular way.