I have got the code to run the same query many times by passing a parameter through as follows:
DoCmd.DeleteObject acTable, "tbl BranchParameter"
Set cmdRunQuery = New ADODB.Command
With cmdRunQuery
.ActiveConnection = CodeProject.Connection
.Properties("Jet OLEDB:Stored Query") = True
.CommandText = "BranchParameter"
.Parameters("[Branch]") = 1000
.Execute
End With
With DoCmd
.RunSQL ("ALTER TABLE [tbl BranchParameter] ADD PRIMARY KEY ([SalesOffice])")
.OutputTo acQuery, "Qry 1i Branch Sector Report", ".xls", "\\sysdevweb\bw\SIC Codes\Work Files\Food Industry\Group.xls", False
End With
But is there anyway I can use the parameter 1000 as the table name in a Make a table query?
i.e. Instead of using the OutputTo command I want use the OpenQuery Command to Make a table called 1000.
DoCmd.DeleteObject acTable, "tbl BranchParameter"
Set cmdRunQuery = New ADODB.Command
With cmdRunQuery
.ActiveConnection = CodeProject.Connection
.Properties("Jet OLEDB:Stored Query") = True
.CommandText = "BranchParameter"
.Parameters("[Branch]") = 1000
.Execute
End With
With DoCmd
.RunSQL ("ALTER TABLE [tbl BranchParameter] ADD PRIMARY KEY ([SalesOffice])")
.OutputTo acQuery, "Qry 1i Branch Sector Report", ".xls", "\\sysdevweb\bw\SIC Codes\Work Files\Food Industry\Group.xls", False
End With
But is there anyway I can use the parameter 1000 as the table name in a Make a table query?
i.e. Instead of using the OutputTo command I want use the OpenQuery Command to Make a table called 1000.