Assume a database table of leads.
Each lead is assigned a sales rep, and has a status, one value being open.
It’s easy to make a report For all open leads, that groups and page breaks by sales rep.
For a weekly meeting, I want to send each sales rep a copy of his open leads.
So the SET OF sales reps can be different each time I run it.
Some reps won’t get anything.
I would be surprised if there’s some built-in way to do this. Then I have definitely overlooked this mechanism for years.
I think I basically have to make two passes… One to build a list of the sales reps that had records in the report, and then a second loop which cycles through each rep, and Emails a report to that rep.
I already did this with some different data, and I called a stored procedure, which does a simple select distinct on sales rep ID, and then I combine all those IDs into a comma delimited string and store in the system settings.
Then I use a WHILE loop (Mark’s looping method) to use each ID to call the subtask, which prints and emails the data for that rep.
Alternatively, I could loop through the employee file, which could be Big, but let’s say I have sales reps marked, which narrows down the list, and I could do a FIND and check SEARCH_COUNT To see if that rep Had Open leads, and if so, run the sub task.
Some people might prefer that since it is keeping it all in aware, which is easier for some.
Do you see another strategy?