I have an unbound form with a button that builds a "where" clause in an Access form filter.
Here is the Button "OnClick" code
Dim strWhere As String
strWhere = " 1=1 " & BuildIn(Me.lboTInterest_ID)
DoCmd.OpenForm "frmEmailResults", acFormDS, , strWhere
DoCmd.Maximize
Here is a sample of what the code puts in the filter
1=1 AND [Interest_ID] In ('5', '1')
This works fine except that if a person has an interest in both 5 and 1, I get their name listed twice.
The form is bound to a query. Here it is....
SELECT Trim([TITLE_PREFIX]) & " " & Trim([FIRST_NAME]) & " " & Trim([MIDDLE_NAME]) & " " & Trim([LAST_NAME]) & " " & Trim([TITLE_SUFFIX]) AS Name, dbo_INDIVIDUAL.EMAIL, dbo_INDIVIDUAL.INDIVIDUAL_ID, *
FROM dbo_INDIVIDUAL INNER JOIN dbo_INTEREST ON dbo_INDIVIDUAL.INDIVIDUAL_ID = dbo_INTEREST.INDIVIDUAL_ID
WHERE (((dbo_INDIVIDUAL.EMAIL) Is Not Null))
ORDER BY dbo_INDIVIDUAL.EMAIL;
I've tried SELECT DISTINCT and SELECT DISTINCTROW in the query but it doesn't seem to help as the filter happens in the form.
I've also tried SELECT TOP 1 in the query and possibly I just didn't get the sort order correct -- though I tried it many different ways -- or perhaps it is again the problem is that the Form is where the filter actually happens.
TIA,
Melanie
Here is the Button "OnClick" code
Dim strWhere As String
strWhere = " 1=1 " & BuildIn(Me.lboTInterest_ID)
DoCmd.OpenForm "frmEmailResults", acFormDS, , strWhere
DoCmd.Maximize
Here is a sample of what the code puts in the filter
1=1 AND [Interest_ID] In ('5', '1')
This works fine except that if a person has an interest in both 5 and 1, I get their name listed twice.
The form is bound to a query. Here it is....
SELECT Trim([TITLE_PREFIX]) & " " & Trim([FIRST_NAME]) & " " & Trim([MIDDLE_NAME]) & " " & Trim([LAST_NAME]) & " " & Trim([TITLE_SUFFIX]) AS Name, dbo_INDIVIDUAL.EMAIL, dbo_INDIVIDUAL.INDIVIDUAL_ID, *
FROM dbo_INDIVIDUAL INNER JOIN dbo_INTEREST ON dbo_INDIVIDUAL.INDIVIDUAL_ID = dbo_INTEREST.INDIVIDUAL_ID
WHERE (((dbo_INDIVIDUAL.EMAIL) Is Not Null))
ORDER BY dbo_INDIVIDUAL.EMAIL;
I've tried SELECT DISTINCT and SELECT DISTINCTROW in the query but it doesn't seem to help as the filter happens in the form.
I've also tried SELECT TOP 1 in the query and possibly I just didn't get the sort order correct -- though I tried it many different ways -- or perhaps it is again the problem is that the Form is where the filter actually happens.
TIA,
Melanie