N
Ngan Bui
I have a table called tblContact with ContactID and
first/last name and such. Another table called
tblContactCategory with CCID, ContactID, and CategoryID
(from tblcategory).
This allows one contact to be in many categories.
On the report menu, I allow the user to choose more than
one category from a listbox by using the ctrl button to
choose. The command button will print a report of mailing
labels for those contacts that match up with those
categories.
The function to do that is:
strSql = "[CategoryID]="
For Each varItem In ctl.ItemsSelected
strSql = strSql & ctl.ItemData(varItem) & " OR
[CategoryID]="
Next varItem
'Trim out the extra [categoryid]= at the end of the SQL
strSql = Left$(strSql, Len(strSql) - 16)
'Open the report based on what category was chosen
DoCmd.OpenReport stDocName, acPreview, , strSql
So if a user choose category 2, 23, and 50, an example of
the SQL string would be: "[CategoryID] = 2 or [CategoryID]
= 23 or [CategoryID] = 50"
The report will just filter out the contacts.
The issue now is I want to exclude the contacts that have
the categoryID of 71 (they are on a listserv). So for
example, if I am on Category 2 but also on Category 71, I
wouldn't be listed in the report.
How can I do this?
Ngan
first/last name and such. Another table called
tblContactCategory with CCID, ContactID, and CategoryID
(from tblcategory).
This allows one contact to be in many categories.
On the report menu, I allow the user to choose more than
one category from a listbox by using the ctrl button to
choose. The command button will print a report of mailing
labels for those contacts that match up with those
categories.
The function to do that is:
strSql = "[CategoryID]="
For Each varItem In ctl.ItemsSelected
strSql = strSql & ctl.ItemData(varItem) & " OR
[CategoryID]="
Next varItem
'Trim out the extra [categoryid]= at the end of the SQL
strSql = Left$(strSql, Len(strSql) - 16)
'Open the report based on what category was chosen
DoCmd.OpenReport stDocName, acPreview, , strSql
So if a user choose category 2, 23, and 50, an example of
the SQL string would be: "[CategoryID] = 2 or [CategoryID]
= 23 or [CategoryID] = 50"
The report will just filter out the contacts.
The issue now is I want to exclude the contacts that have
the categoryID of 71 (they are on a listserv). So for
example, if I am on Category 2 but also on Category 71, I
wouldn't be listed in the report.
How can I do this?
Ngan