I am working on generating mailing labels from the same MultiSelect form I was working on for reports earlier in the week. The form allows you to select any set of groups of people and then print the listing of the members of that group.
For the mailing labels, I want to remove duplicates which can be created if the same person is a member of more than one group. It seems to me that I need to generate the recordset of all the people in the selected groups then run a new SELECT DISTINCTROW query which will filter out the duplicates, then print the labels. I’m just not sure of the recipe I need to follow to accomplish this.
I am working on the following assumptions: After selecting the list of groups to print labels for, the user clicks a command button. The code in the on click event loops through the list of groups using the same select case statements as for the lists of members that I was working on previously. After constructing the Where clause, a query is created in code to just have that group of people. From that query, a second one uses DISTINCTROW to pull out unique names and addresses. The labels are then generated.
My questions are: Should these two queries that are created in code be created with the queryDef object (I haven’t actually had to use this before) or some other way? What is the recordsource for the labels report if these queries are created in code? And what syntax should I use if the recordsource isn’t a saved query? How do I send the SELECT DISTINCTROW info to the labels report?
The underlying set of records that the command button calls on is the same saved query that the other report is generated from. Hopefully this makes sense.
Peter