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


PHP:
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

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

Forum statistics

Threads
1,215,778
Messages
6,126,841
Members
449,343
Latest member
DEWS2031

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
Back
Top