Pete,
Since this involves a process of cycling through a set of records and
performing an action for each one, this is one area where VBA procedure
shines compared with a macro approach.
The problem is that neither the OutputTo or TransferSpreadsheet methods
(I assume you are using one of these) supports a Where condition argument.
So one thing you can do is use code to manipulate the SQL property of
the query, to create an instance of the query for each criteria value.
I assume you have a query or table that lists the account managers, in a
field I assume is called AMName. So in my example I will call this
"ListOfManagers". And I will use "YourQuery" as the name of your
central query with no criteria in it. In which case, here is some
example code:
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim qdf As DAO.QueryDef
Dim strSQL As String
Dim BaseSQL As String
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("SELECT AMName FROM ListOfManagers")
Set qdf = dbs.QueryDefs("YourQuery")
BaseSQL = Left(qdf.SQL, Len(qdf.SQL)-3)
With rst
Do Until .EOF
strSQL = BaseSQL & " WHERE AMName=" & """" & ![AMName] & """"
qdf.SQL = strSQL
DoCmd.OutputTo acOutputQuery, "YourQuery", ...etc
.MoveNext
Loop
.Close
End With
qdf.SQL = BaseSQL
Set qdf = Nothing
Set rst = Nothing
Set dbs = Nothing