473,652 Members | 2,935 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Filtering results by condition in query? (Access 2010)

4 New Member
I hope this isn't too confusing for you to be able to assist me.

I have a requirement to produce a yes/no result in a form field based on a range of conditions in a query. We are a service which delivers support for frail aged clients daily based on their individual requirements. For any particular client we need to know whether they require a service call today or any selected day, based on the following conditions:

Certain days the client has selected not to be called (e.g. no call Mon, Wed, Fri).
Days selected at random based on the client's variable requirements (e.g. no call from 1/1/16 to 3/1/16 etc.)

I can set up my tables and query to produce a yes/no result for each option (by yes/no on each day of the week and a table of From-to dates for the casual selections, and an IIF expression to check each variable to produce a Yes/No result for each variable).

When I run the query I may get multiple results for any client based on each condition, but if I get a "No" result for at least one result in the query for a particular date based on the above then the result is "No" for that day.

e.g.

John - No Call Mon, Wed (Today is Sat) = Yes
John - No Call from 10/8/15 to 18/8/15 (Today is 15/8/15) = No
Etc.

(I hope you are still with me!)

How do I show a "No" or "yes" in a text field based on a Date/Time filter on a form or report which shows a "Yes" by default and a "No" if ANY result in the query result list for that client is a "No"?
Aug 15 '15 #1
5 1135
Rabbit
12,516 Recognized Expert Moderator MVP
Basically you have a queries that return a bunch of yes's and no's. You just want to return a no if there are any no's. Is that correct?

Take that query, and return the Min() of the yes/no field. If there are any no's it will return no because n is "smaller" than y.
Aug 15 '15 #2
stevekos07
4 New Member
That didn't work. When I ran the query with the Min criteria it produced no results. I actually don't want to filter out values per client, I just want the most valid result for all of the conditions. For instance a client may have one 'set' of days of the week that they select for no calls, but they may have more than one 'From-To' set of dates in addition. e.g. Normally call on Mondays, but for the next two mondays no call. This would not be a permanent change.

This is my expression in the query to give you an idea:

CallToday: IIf([Date]>=[tblClientNoCall Days].[NoCallFrom] And [Date]<=[tblClientNoCall Days].[NoCallTo]
Or Weekday([Date],1)=1 And [Sun]=True
Or Weekday([Date],1)=2 And [Mon]=True
Or Weekday([Date],1)=3 And [Tue]=True
Or Weekday([Date],1)=4 And [Wed]=True
Or Weekday([Date],1)=5 And [Thu]=True
Or Weekday([Date],1)=6 And [Fri]=True
Or Weekday([Date],1)=7 And [Sat]=True,"No","Yes ")
Aug 15 '15 #3
stevekos07
4 New Member
Here is a screenshot of the results. You might comment that my multiple columns of days breaks normalisation, which technically it does, but it works, and as days of the week are hardly going to increase or decrease any time soon, the format is as stable as any other way of presenting this.

Aug 15 '15 #4
Rabbit
12,516 Recognized Expert Moderator MVP
You don't put the min in the criteria, it goes in the select clause.

If you want to keep all the rows, then you still need the min, you just then have to join that result back to the full data set
Aug 15 '15 #5
stevekos07
4 New Member
Thanks for that Rabbit. That worked. I have a couple of other challenges with this to deal with though before it is done. There can be exceptions to the regular no-call days as well, so I am adding an "Exceptions " field as a final logical test. As a relative newcomer to Access this has been a real test for me too, but I'm getting there :).
Aug 15 '15 #6

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

Similar topics

5
12415
by: jaad | last post by:
Hello, I have a database that was written in access 2007 on my pc. I wanted to work off site with the database so I uploaded it onto my laptop which is loaded with access 2010 beta. When I finished working with the database and return it to my pc(which has access 2007) I can't get it open because Access say that the file is not the right format. Does anyone have a way to work around this compatibility problem? So you know I...
2
6703
by: sierra7 | last post by:
It seems Access 2010 is associating an 'input mask' or field type with a combo box when a form is opened, even though there is no Format setting on the control. I have a form which has been running OK for years in Access 2003; it adds an item selected from an inventory listing to either an existing Sales Order or Purchase Order. For historic reasons Purchase orders are alphanumeric and Sales orders are numeric (long integer). The RowSource...
4
31377
by: jbrumbau | last post by:
Hello, In Access 2010/2007, how do you prevent users from flipping into design view from the ribbon? I do not want to hide the entire ribbon (DoCmd.ShowToolbar "Ribbon", acToolbarNo) or even the "View" part of the "Home" tab because users like being able to flip between Form View and Datasheet View in the forms. It turns out that on our network, if a user inadvertantly clicks Design View, then the database becomes locked to new users until...
3
6061
by: john latona | last post by:
hi! i realize that access 2010 does not have the username and password function built into it, so i am trying to build it into my db. i have a "login form" with text fields titled username and password. i also have a table containing all usernames and passwords. i also have a query that references the table with criteria set to match the form text box data with the table data. this "verification" occurs on click on a button on the fowm....
17
12389
twinnyfo
by: twinnyfo | last post by:
Hey coders, Has anyone heard anything about the Date() function no longer working (or working differently in MS Access 2010? I have an MS Access 2007 DB that has worked perfectly, however, we have a bunch of machines running on the same front end, and the machine with MS Access 2010 generates an error that the function cannot be found in the line of code that uses that function. Any ideas? This is the line of the query that generates...
7
7966
dgaletar
by: dgaletar | last post by:
To start off, I am a serious "newbe" to Access, and have probably made countless mistakes thus far in the design of this database. I work as a fleet mechanic for a University in DC, and am trying to keep track of the maintenance on our vehicles. To do this I created a pretty simple Access 2010 database. Everything was going pretty well until I realized that I couldn't go any further without some help... so here I am! In an effort to...
11
2697
by: Redbeard | last post by:
I have just upgraded to Access 2010 (64 bit) from Access 2007. There were a few minor issues in the database which I have resolved but this one piece of code just won’t work. I do not write VBA but have a rudimentary understanding of it. This code was not written by me and I am still trying to understand why it doesn’t work? I have posted the code below; this is what it is supposed to do: I have a main form that displays each record. The form...
3
2172
by: time2hike | last post by:
Hi, I have a query that pulls in hours for multiple Subprojects by Month and Year. To be able to compare data I need to Count the Month & Year for each subproject. Example Subproject1 11/2011 would be 1, Subproject 1 12/2011 would be 2, and Subproject2 3/2009 would be 1. So, I am trying to use a DCount in an Access 2010 query. This is my SQL: SELECT qLbrEstModelBaseHours.SUBPROJECTID, qLbrEstModelBaseHours.FISCALYEAR,...
6
2066
by: mlgmlg | last post by:
Hello, I desperately need help to modify a where condition that was created when I added a button to open a form and find specific data by to display. The form currently opens and displays a form filtered by the task num (where condition below). ="=" & "'" & & "'" This works great. When I click on the button, a form (Contractors) pop-ups and displays all records filtered by task num. Now, I would like to perform another filter on...
0
8283
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8811
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8470
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7302
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5620
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4147
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2707
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1914
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1591
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.