473,395 Members | 1,464 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Filter Function Results

Access 2003
I have a series of IIF/Select statements providing true/false analysis on a number of criteria (see code below), basically checking each table entry for specific criteria and spitting out text (ie: "Check This, It's Not Right") for my report. Once I've checked all these criteria, I want to filter my report to only show me data that doesn't meet at least one of the five criteria.

The data is coming from a linked, imported table, and I'm not able to place validation criteria on data entry (partly because some of the 'errors' this report identifies are actually acceptable anomalies).

I'm starting from this:
Expand|Select|Wrap|Line Numbers
  1. SELECT Qcv.Title, Qcv.Course, Qcv.Sec, Qcv.Location, Qcv.Room, Qcv.Day, Qcv.Start, Qcv.End, Qcv.Start1, Qcv.End1, IIf([Start1] In (select StandardDate from Dates),"","Check Start Date") AS StartDateCheck, IIf([End1] In (select StandardDate from Dates),"","Check End Date") AS EndDateCheck, IIf([Start] In (select SlotStart from Slots),"","Check Slot Start Time") AS SlotStartCheck, IIf([End] In (select SlotEnd from Slots),"","Check Slot End Time") AS SlotEndCheck, IIf([Location]="MAIN",IIf([Room] Is Null,"Loc. MAIN No Room",""),"") AS LocationCheck, IIf([StartDateCheck]="",IIf([EndDateCheck]="",IIf([SlotStartCheck]="",IIf([SlotEndCheck]="",IIf([LocationCheck]="","PASSED ALL CHECKS",""),""),""),""),"") AS CheckAll
  2. FROM Qcv;
  3.  
When I try to add criteria, ie:
Expand|Select|Wrap|Line Numbers
  1. WHERE ((Not (IIf([StartDateCheck]="",IIf([EndDateCheck]="",IIf([SlotStartCheck]="",IIf([SlotEndCheck]="",IIf([LocationCheck]="","PASSED ALL CHECKS",""),""),""),""),""))="PASSED ALL CHECKS"));
It asks me to define each of the terms (running the Access Query viewer), or in a report it says "Query is too complex."

I appreciate that there are easier ways of building this kind of query, but my dataset is relatively small (2600 entries), and I only need to run this report a dozen times a year. And... I'm completely new to SQL (started learning two weeks ago), so your patience in explaining is greatly appreciated.

What am I doing wrong? Is there a better way of filtering my data?

Thanks!

Joel
Oct 27 '11 #1
1 1692
NeoPa
32,556 Expert Mod 16PB
Joel,

I already explained in another thread that this should be done using LEFT JOINs. Now you're asking again if there is a better way available. Do you really thingk the correct answer is going to change depending on how many times you ask the question. I can confidently assure you it won't.

Unfortunately for your current approach the WHERE clause, quite sensibly, is processed before the SELECT clause. This means that the ALIASes (AS) you've defined in the SELECT clause are not available to the WHERE clause as you've tried to use them.

The format of a WHERE clause is :
Expand|Select|Wrap|Line Numbers
  1. WHERE ([X] = Y)
  2.   AND ([Z] In (A,B,C)
  3.   AND (etc))
What you have doesn't follow that simple approach so is fundamentally unrecognisable to the SQL engine (Hence the error message).
Oct 28 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: NRGY | last post by:
Hi. I need help with a filtering function that I can't get to whatever I try. I have this output that I need to filter: <tr> <td class="box_content" align="center">3,259</td> <td...
11
by: wackyphill | last post by:
I want to create a stored procedure that returns a list of records from a table. But depending on a userID value given only certain records will be returned that they have access to. I think...
38
by: Lasse Vågsæther Karlsen | last post by:
After working through a fair number of the challenges at www.mathschallenge.net, I noticed that some long-running functions can be helped *a lot* by caching their function results and retrieving...
3
by: bay_dar | last post by:
Hi my dirty word filter function has a problem, it is over restrictive. For instance the word "analysis" is ok, but the word "anal" is not. Any advice? code below: Public Function...
4
by: hadardo | last post by:
Hello all. Let me start by saying that I don't use VBA so often, so I ask for your forgivness if my questions is somewhat silly. I'm trying to find if a user typed the same value in two or more...
5
by: NewtoAccess | last post by:
Hi its me again. I want to filter data by 2-different values. First I want to filter data by site and then by server. the first value is obtained from a list box-this works fine, then I want the...
1
by: Barb.Richards | last post by:
I have created an append query that pulls information from one database, and will append the selected information into a new table. The fields are setup like 'number' 'category' 'code' 'shares' and...
1
by: david.katkowski | last post by:
I'm trying to use the __builtin__ filter function within a class; however, I receive the following error: NameError: global name 'MajEthnic' is not defined The line of code is: EthMaj =...
1
by: kang jia | last post by:
hi i am quite confused between get() function and filter() function, what is the difference between. it seems they all retrieve the specific row from database. i have written this code in one...
1
by: Terry Reedy | last post by:
John Townsend wrote: The latter. Other functions could be wrapped to bind all parameters except the list element. Or write an explicit loop.
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.