|
|
|||||||||
|
|||||||||
|
|||||||||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
|
|
#1
|
|||
|
|||
|
Queries - Issue with a query
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 - DOES NOT WORK 2. User leaves both fields blank - no specific person and no specific company - query returns all rows 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 here is the criteria part of the query 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] & "*")) ---I would really appreciate any help |
|
#2
|
||||
|
||||
|
Have you tried simply:
Code:
WHERE tblClientReport.Company) Like "'" & [forms]![frmClientReportFields].[Company] & "*'" AND tblClientReport.Individual) Like "'" & [forms]![frmClientReportFields].[Individual] & "*'"
__________________
Experience is the thing you have left when everything else is gone. |
|
#3
|
|||
|
|||
|
yes, I tried that too
the criteria for no input for a indidudual and specified company still does not work. All companies are being returned |
|
#4
|
||||
|
||||
|
Quote:
Preferred format: Code:
tblClientReport:
ID
Company
Individual
...
It would result in one of the following: Code:
WHERE Company LIKE 'IBM*' AND Individual LIKE 'Jones*' or WHERE Company LIKE 'IBM*' AND Individual LIKE '*' or WHERE Company LIKE '*' AND Individual LIKE 'Jones*' or WHERE Company LIKE '*' AND Individual LIKE '*' |
|
#5
|
|||
|
|||
|
Code:
SELECT tblClientReport.Individual, tblClientReport.Company FROM tblClientReport WHERE (((tblClientReport.Individual) Like "*" & [forms]![frmClientReportFields]![individual] & "*") AND ((tblClientReport.Company) Like "*" & [forms]![frmClientReportFields]![company] & "*")); This query works for me: This was my dataset: Code:
tblClientReport Individual Company John Doe Acme, Inc. Jane Doe Acme, Inc. Mickey Mouse Acme, Inc. Donald Duck Disney, Inc. Minnie Mouse Disney, Inc. With a form named frmClientReportFields with two text boxes named INDIVIDUAL and COMPANY When both are blank, I get all companies/individuals When just a company is present I get everyone associated with that portion of a company name. When just an individual is present I get all companies associated with that portion of an individual name When both are filled in I get only the records that are associated with that portion of an individual name and company name.
__________________
---------------- If we've helped you and you have solved your problem please post that it's been resolved so we know! The suspense kills me! |
![]() |
| Viewing: ASP Free Forums > Database > Microsoft Access Help > Queries - Issue with a query |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|
|