Passing a parameter to a macro

karl1171

New Member
Joined
Jan 18, 2008
Messages
22
I'm using the following code to pass a value (which will eventually be contained in a text string) to a query/procedure


Code:
Sub TestCmd()
Dim Cat As Object
 
Set Cat = CreateObject("ADOX.Catalog")
With Cat
.ActiveConnection = _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=S:\Reporting database.mdb"
Dim cmd As Object
Set cmd = .Procedures("Top 5 Reason codes").Command
End With
With cmd
.Parameters("[forms]![subform]![combo58]").Value = "dept code"
.Execute
End With
End Sub

However there are a further 7 queries which I need to run using a macro called Generate New Format Report: the macro just opens the 8 queries together.

I can use the line

DoCmd.RunMacro "Generate New Format Report"

to run the macro but don't know how to pass the parmater to this: I'm assuming the code will be similar to the above, or i can somehow loop to get the value to pass to each query in turn
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,068
Messages
5,835,204
Members
430,345
Latest member
Yousef081

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top