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

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.

Watch MrExcel Video

Forum statistics

Threads
1,130,333
Messages
5,641,550
Members
417,220
Latest member
lam150498

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