Re: Filter a list containing null values
- From: "Ken Snell [MVP]" <kthsneisllis9@xxxxxxxxxxxxxxxxxx>
- Date: Mon, 22 Jun 2009 11:16:33 -0400
You need to change your WHERE clause so that you're testing for NULL in the
combo box's value, not in the table's field's value. Here is the first
grouping from your current WHERE clause:
WHERE (((tblProjectData.PROJDescription) Like "*" &
[Forms]![frmProjectList]![DescriptionSearch] & "*" Or
(tblProjectData.PROJDescription) Is Null) AND
The above needs to be changed to this:
WHERE (((tblProjectData.PROJDescription) Like "*" &
[Forms]![frmProjectList]![DescriptionSearch] & "*" Or
[Forms]![frmProjectList]![DescriptionSearch] Is Null) AND
--
Ken Snell
<MS ACCESS MVP>
http://www.accessmvp.com/KDSnell/
Make the same type of change in all the other groupings in the WHERE clause.
"Wendymel" <Wendymel@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:3392F20E-C2B8-43A3-9BC0-517F5E66A47C@xxxxxxxxxxxxxxxx
I have a form (frmProjectList) with a subform (frmSubProjectList)
containing
a list of all the records in the db.
In the form I have 7 unbound combo lists that are used to filter the list
either separately, or in combination. The all worked fine up until the
users
decided that some of the fields will not contain any information (null or
blank). Now when the combo boxes are used to filter the list, they
include
not only the correct records, but the records with Null or blank values in
the fields that have just been filtered.
My subform record source is a query (qryProjects). My combo boxes all use
a
row source type table/query with an after update and on change event of
DoCmd.Requery "frmSubProjectList"
For example, the subform qryProjects reads:
SELECT tblProjectData.ProjectUNID, tblProjectData.PROJDescription,
tblProjectData.PROJBudget, tblProjectData.CurrentProjAuth,
tblProjectData.ProjectNumber, tblProjectNumber.ProjectNumber,
tblProjectData.PROJBudgetYear, tblBudgetYear.BudgetYear,
tblProjectData.PROJLocation, tblLocation.Location,
tblProjectData.ProjectStatus, tblProjStatus.ProjectStatus,
tblProjectData.PROJFundingType, tblFundingType.FundingSourceType,
tblProjectData.PROJAssignedPriority,
tblAssignedPriority.AssignedPriorityDetail, tblProjectData.ProjectManager,
tblProjManager.ProjectManager
FROM tblFundingType RIGHT JOIN (tblBudgetYear RIGHT JOIN (tblProjectNumber
RIGHT JOIN (tblAssignedPriority RIGHT JOIN (tblProjStatus RIGHT JOIN
(tblProjManager RIGHT JOIN (tblLocation RIGHT JOIN tblProjectData ON
tblLocation.Location = tblProjectData.PROJLocation) ON
tblProjManager.ProjectManager = tblProjectData.ProjectManager) ON
tblProjStatus.ProjectStatus = tblProjectData.ProjectStatus) ON
tblAssignedPriority.AssignedPriority =
tblProjectData.PROJAssignedPriority)
ON tblProjectNumber.ProjectNumber = tblProjectData.ProjectNumber) ON
tblBudgetYear.BudgetYear = tblProjectData.PROJBudgetYear) ON
tblFundingType.FundingSourceType = tblProjectData.PROJFundingType
WHERE (((tblProjectData.PROJDescription) Like "*" &
[Forms]![frmProjectList]![DescriptionSearch] & "*" Or
(tblProjectData.PROJDescription) Is Null) AND
((tblProjectNumber.ProjectNumber) Like "*" &
[Forms]![frmProjectList]![cbopProjectNumberChoice] & "*" Or
(tblProjectNumber.ProjectNumber) Is Null) AND ((tblBudgetYear.BudgetYear)
Like "*" & [Forms]![frmProjectList]![cboBudgetYearChoice] & "*" Or
(tblBudgetYear.BudgetYear) Is Null) AND ((tblLocation.Location) Like "*" &
[Forms]![frmProjectList]![cboLocationChoice] & "*" Or
(tblLocation.Location)
Is Null) AND ((tblProjStatus.ProjectStatus) Like "*" &
[Forms]![frmProjectList]![cboStatusChoice] & "*" Or
(tblProjStatus.ProjectStatus) Is Null) AND
((tblFundingType.FundingSourceType) Like "*" &
[Forms]![frmProjectList]![cboFundingChoice] & "*" Or
(tblFundingType.FundingSourceType) Is Null) AND
((tblAssignedPriority.AssignedPriorityDetail) Like "*" &
[Forms]![frmProjectList]![cboAssignedPriorityChoice] & "*" Or
(tblAssignedPriority.AssignedPriorityDetail) Is Null) AND
((tblProjManager.ProjectManager) Like "*" &
[Forms]![frmProjectList]![cboProjectManagerChoice] & "*" Or
(tblProjManager.ProjectManager) Is Null))
ORDER BY tblProjectData.ProjectNumber;
An example of one of the unbound combo box filters is:
Project Manager
Row Source: SELECT ProjectManager FROM tblProjManager ORDER BY
[ProjectManager];
If a user selects a project manager from the list named JSmith then the
list
is filtered down to all projects with a project manager JSmith as well as
the
records that have no project manager (blank or null)
I do not want the null values included in the result set.
I have been beating my head against the wall on this one. The answer is
probably very simple, I just need fresh eyes to look at it.
Thanks
.
- Follow-Ups:
- Re: Filter a list containing null values
- From: Wendymel
- Re: Filter a list containing null values
- References:
- Filter a list containing null values
- From: Wendymel
- Filter a list containing null values
- Prev by Date: Re: Predictive text in a Filter
- Next by Date: Re: Calculate distance between two points (numbers) in a number line
- Previous by thread: Re: Filter a list containing null values
- Next by thread: Re: Filter a list containing null values
- Index(es):
Relevant Pages
|