Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Queries / May 2008

Tip: Looking for answers? Try searching our database.

Simple Select Query - To Complicated?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Love Buzz - 22 May 2008 15:45 GMT
Hello everyone.

It seems like I am posting daily these days.  I have only been using MS
Access since Novemberish and I appreciate all of the assistance I get when I
post.

Today's issue is just a simple query trying to count only those fiels in my
table (errors) that equal Y.  When I run the query I get the message 'the
expression is typed incorrectly, or it is too complex to be evaluated.'

Here is my SQL.  Thank you for your assistance.

SELECT Errors.[User ID], Count(Errors.[Error Indicator]) AS [CountOfError
Indicator], Count(Errors.[Customer Impact?]) AS [CountOfCustomer Impact?],
Count(Errors.[Loss?]) AS [CountOfLoss?], Count(Errors.[Caught on Quality
Check?]) AS [CountOfCaught on Quality Check?]
FROM Errors
WHERE (((Errors.[Notification Date]) Between [Start Date] And [End Date]))
GROUP BY Errors.[User ID]
HAVING (((Count(Errors.[Customer Impact?]))="Y") AND
((Count(Errors.[Loss?]))="Y") AND ((Count(Errors.[Caught on Quality
Check?]))="Y"));
John Spencer - 22 May 2008 16:07 GMT
Count(somefield) is always going to return a NUMBER.  A Number cannot be
compared to "Y"

SELECT Errors.[User ID]
, Count(Errors.[Error Indicator]) AS [CountOfError Indicator]
, Count(IIF(Errors.[Customer Impact?]="Y",1,Null)) AS [CountOfCustomer Impact?]
, Count(IIF(Errors.[Loss?]="Y",1,Null)) AS [CountOfLoss?]
, Count(IIF(Errors.[Caught on Quality Check?]="Y",1,Null)) AS [CountOfCaught
on Quality Check?]
FROM Errors
WHERE (((Errors.[Notification Date]) Between [Start Date] And [End Date]))
GROUP BY Errors.[User ID]

John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County

> Hello everyone.
>
[quoted text clipped - 18 lines]
> ((Count(Errors.[Loss?]))="Y") AND ((Count(Errors.[Caught on Quality
> Check?]))="Y"));
Love Buzz - 22 May 2008 18:24 GMT
Thank you sir.  That did the trick.  

> Count(somefield) is always going to return a NUMBER.  A Number cannot be
> compared to "Y"
[quoted text clipped - 36 lines]
> > ((Count(Errors.[Loss?]))="Y") AND ((Count(Errors.[Caught on Quality
> > Check?]))="Y"));
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.