Microsoft Access Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Iron Speed
Go Back   ASP Free ForumsDatabaseMicrosoft Access Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
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  
Old May 8th, 2008, 12:05 PM
Irina_5220 Irina_5220 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2008
Posts: 5 Irina_5220 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 21 m
Reputation Power: 0
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

Reply With Quote
  #2  
Old May 8th, 2008, 02:09 PM
don94403's Avatar
don94403 don94403 is offline
Contributing User
ASP Free Beginner (1000 - 1499 posts)
 
Join Date: Jan 2007
Location: Northern California
Posts: 1,171 don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 32 m 3 sec
Reputation Power: 251
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.

Reply With Quote
  #3  
Old May 8th, 2008, 02:55 PM
Irina_5220 Irina_5220 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2008
Posts: 5 Irina_5220 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 21 m
Reputation Power: 0
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

Reply With Quote
  #4  
Old May 8th, 2008, 03:45 PM
don94403's Avatar
don94403 don94403 is offline
Contributing User
ASP Free Beginner (1000 - 1499 posts)
 
Join Date: Jan 2007
Location: Northern California
Posts: 1,171 don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 32 m 3 sec
Reputation Power: 251
Quote:
Originally Posted by Irina_5220
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
Show us what your table structure looks like, perhaps there's a problem there.

Preferred format:
Code:
tblClientReport:
    ID
    Company
    Individual
    ...
Is it anything like that? If so, I think the criteria I suggested should work.

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 '*'
All of those should produce the results you want, I believe.

Reply With Quote
  #5  
Old May 8th, 2008, 03:58 PM
rpeare rpeare is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jan 2008
Posts: 467 rpeare User rank is First Lieutenant (10000 - 20000 Reputation Level)rpeare User rank is First Lieutenant (10000 - 20000 Reputation Level)rpeare User rank is First Lieutenant (10000 - 20000 Reputation Level)rpeare User rank is First Lieutenant (10000 - 20000 Reputation Level)rpeare User rank is First Lieutenant (10000 - 20000 Reputation Level)rpeare User rank is First Lieutenant (10000 - 20000 Reputation Level)rpeare User rank is First Lieutenant (10000 - 20000 Reputation Level)rpeare User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 4 Days 7 m 47 sec
Reputation Power: 117
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!

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseMicrosoft Access Help > Queries - Issue with a query


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway