I
Irina
Hello, I am desperately needing help with this query.
Basically, I have 4 criteria that I want the query to evaluate correctly
in a form. User has 2 fields to input - individual and company.
But I also want the query to work if a user leave either company blank
or individual name blank or both.
Here is the list of criteria
1. User will input a company name and leave individual name blank - query
supposed to return all people at a certain company -this one does not work!!!!
2. User leaves both fields blank - no specific person and no specific
company - query returns all rows - works
3. User types in a specfic last name and specific company - specific
individual at a specific company - works
4. User types a name in and no company - this only works with 2"LIKE"
in the 1st and 4th criteria in the query.
If I take the last "LIKE" out - then it does not work BUT criteria 1 works.
Basically the issue is that i have 3 criterias working, and either 4 works
(2"Like" - in the 3 & 4th) and 1 does not. Or 1 works but 4 does not with
(1"like")
Like left in 3rd criteria and taken out of 4th.
please review this and you will understand what I mean.
--------------------------------------------------------------
SELECT tblClientReport.Individual, tblClientReport.Company,
tblClientReport.[Job Title], tblClientReport.WorkLocation,
tblClientReport.[Current Status], tblClientReport.[Expiration Date],
tblClientReport.[Maximum Potential Stay], tblClientReport.[Place of Birth],
tblClientReport.Citizenship, tblClientReport.[Permanent Residence
Authorization], tblClientReport.[Dates Children turn 21],
tblClientReport.[Resp Att], tblClientReport.RepresentativeTitle,
tblClientReport.RepresentativeName, tblClientReport.[Priority Date],
tblClientReport.[Immigration Classification], tblClientReport.Comments,
tblClientReport.CaseName, tblClientReport.[Resp Associate/Paralegal],
tblClientReport.ClientNumber, tblClientReport.MatterNumber,
tblClientReport.HR, tblClientReport.[Business Unit], tblClientReport.[Legal
Presicion number requested], tblClientReport.[File Name],
tblClientReport.[I-140/Labor Certification], tblClientReport.Dept,
tblClientReport.[18 Month from Date of Selection],
tblClientReport.[College/Division], tblClientReport.[Hard Copy Ad Run],
forms!frmClientReportFields.Individual AS Expr1
FROM tblClientReport
WHERE
'all people at a certain company -does not work
(((tblClientReport.Company)=[forms]![frmClientReportFields].[Company]) AND
(([forms]![frmClientReportFields].[Individual]) Is Null)) OR
"no specific person and no specific company - query returns all rows
((([forms]![frmClientReportFields].[Individual]) Is Null) AND
(([forms]![frmClientReportFields].[Company]) Is Null)) OR
'specific individual at a specific company
(((tblClientReport.Individual) Like
[forms]![frmClientReportFields].[Individual] & "*") AND
((tblClientReport.Company)=[forms]![frmClientReportFields].[Company])) OR
'this is criteria for an individuals with the same last name but working for
different companies, ex. Smith, J. works for Kodak
Smith, K. works for Xeorox
(((tblClientReport.Individual) Like
[forms]![frmClientReportFields].[Individual] & "*"))
Basically, I have 4 criteria that I want the query to evaluate correctly
in a form. User has 2 fields to input - individual and company.
But I also want the query to work if a user leave either company blank
or individual name blank or both.
Here is the list of criteria
1. User will input a company name and leave individual name blank - query
supposed to return all people at a certain company -this one does not work!!!!
2. User leaves both fields blank - no specific person and no specific
company - query returns all rows - works
3. User types in a specfic last name and specific company - specific
individual at a specific company - works
4. User types a name in and no company - this only works with 2"LIKE"
in the 1st and 4th criteria in the query.
If I take the last "LIKE" out - then it does not work BUT criteria 1 works.
Basically the issue is that i have 3 criterias working, and either 4 works
(2"Like" - in the 3 & 4th) and 1 does not. Or 1 works but 4 does not with
(1"like")
Like left in 3rd criteria and taken out of 4th.
please review this and you will understand what I mean.
--------------------------------------------------------------
SELECT tblClientReport.Individual, tblClientReport.Company,
tblClientReport.[Job Title], tblClientReport.WorkLocation,
tblClientReport.[Current Status], tblClientReport.[Expiration Date],
tblClientReport.[Maximum Potential Stay], tblClientReport.[Place of Birth],
tblClientReport.Citizenship, tblClientReport.[Permanent Residence
Authorization], tblClientReport.[Dates Children turn 21],
tblClientReport.[Resp Att], tblClientReport.RepresentativeTitle,
tblClientReport.RepresentativeName, tblClientReport.[Priority Date],
tblClientReport.[Immigration Classification], tblClientReport.Comments,
tblClientReport.CaseName, tblClientReport.[Resp Associate/Paralegal],
tblClientReport.ClientNumber, tblClientReport.MatterNumber,
tblClientReport.HR, tblClientReport.[Business Unit], tblClientReport.[Legal
Presicion number requested], tblClientReport.[File Name],
tblClientReport.[I-140/Labor Certification], tblClientReport.Dept,
tblClientReport.[18 Month from Date of Selection],
tblClientReport.[College/Division], tblClientReport.[Hard Copy Ad Run],
forms!frmClientReportFields.Individual AS Expr1
FROM tblClientReport
WHERE
'all people at a certain company -does not work
(((tblClientReport.Company)=[forms]![frmClientReportFields].[Company]) AND
(([forms]![frmClientReportFields].[Individual]) Is Null)) OR
"no specific person and no specific company - query returns all rows
((([forms]![frmClientReportFields].[Individual]) Is Null) AND
(([forms]![frmClientReportFields].[Company]) Is Null)) OR
'specific individual at a specific company
(((tblClientReport.Individual) Like
[forms]![frmClientReportFields].[Individual] & "*") AND
((tblClientReport.Company)=[forms]![frmClientReportFields].[Company])) OR
'this is criteria for an individuals with the same last name but working for
different companies, ex. Smith, J. works for Kodak
Smith, K. works for Xeorox
(((tblClientReport.Individual) Like
[forms]![frmClientReportFields].[Individual] & "*"))