A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Query Group By Criteria



 
 
Thread Tools Display Modes
  #1  
Old January 6th, 2008, 10:08 PM posted to microsoft.public.access.forms
pushrodengine via AccessMonster.com
external usenet poster
 
Posts: 106
Default Query Group By Criteria

I need to query to show all records except records that include the text
"Code 1” and “Code 4” and “Code 5” in "Details" feild.

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...forms/200801/1

  #2  
Old January 6th, 2008, 11:11 PM posted to microsoft.public.access.forms
Ken Snell \(MVP\)
external usenet poster
 
Posts: 2,506
Default Query Group By Criteria

SELECT *
FROM TableName
WHERE [Details] 'Code 1' AND
[Details] 'Code 4' AND
[Details] 'Code 5';

--

Ken Snell
MS ACCESS MVP


"pushrodengine via AccessMonster.com" u36225@uwe wrote in message
news:7dd2aeff1e7b3@uwe...
I need to query to show all records except records that include the text
"Code 1" and "Code 4" and "Code 5" in "Details" feild.

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...forms/200801/1



  #3  
Old January 7th, 2008, 01:03 AM posted to microsoft.public.access.forms
John W. Vinson
external usenet poster
 
Posts: 18,261
Default Query Group By Criteria

On Sun, 06 Jan 2008 22:08:58 GMT, "pushrodengine via AccessMonster.com"
u36225@uwe wrote:

I need to query to show all records except records that include the text
"Code 1 and Code 4 and Code 5 in "Details" feild.


Ken's answer will give you the desired result if that's ALL that's in the
Details field. If you want to exclude records where the Details field includes
these strings along with other text (e.g. "This item deals with a Code 4
issue") then you may have a problem: will there be any Code 10 or Code 42
records?

If not... a criterion on Details of

NOT LIKE "*Code [145]*"

will work.

If you want to exclude "This is a Code 1 item" and "This item is Code 1" but
DO want to see "This item is Code 10", you'll need a dual criterion:

NOT LIKE "*Code [145] *" AND NOT LIKE "*Code [145]"


John W. Vinson [MVP]
  #4  
Old January 7th, 2008, 01:23 AM posted to microsoft.public.access.forms
pushrodengine via AccessMonster.com
external usenet poster
 
Posts: 106
Default Query Group By Criteria

Prefect, Thanks. I need something else that is similar.

Show all records except records that have the text "Code 8”, “Code 11”, “Dry
Run - Canceled Enroute”, "Dry Run - UTL Incident", "Public Assist" and
"Station Coverage" in "CallDetails" feild.

--
Message posted via http://www.accessmonster.com

  #5  
Old January 7th, 2008, 01:32 AM posted to microsoft.public.access.forms
John W. Vinson
external usenet poster
 
Posts: 18,261
Default Query Group By Criteria

On Mon, 07 Jan 2008 01:23:01 GMT, "pushrodengine via AccessMonster.com"
u36225@uwe wrote:

Show all records except records that have the text "Code 8, Code 11, Dry
Run - Canceled Enroute, "Dry Run - UTL Incident", "Public Assist" and
"Station Coverage" in "CallDetails" feild.


The need to do this suggests that your table design needs work. Rather than
embedding what appears to be a CallType field in a (free form? typed in?) text
field - where the user could type "Dry run; UTL Incident" or "Public Asisst"
(causing the record to be miscategorized), I'd really suggest that you need a
CallCode field separate from the CallDetails field. This could use a combo box
based on a CallCodes table with the various types of call, including these.

You can DO this by adapting my suggested code... but it will be inefficient,
all but impossible to maintain, and error prone. Don't do it!

John W. Vinson [MVP]
  #6  
Old January 7th, 2008, 01:51 AM posted to microsoft.public.access.forms
pushrodengine via AccessMonster.com
external usenet poster
 
Posts: 106
Default Query Group By Criteria

The user must select from a Combo box only. They can't enter just anything.
So, "Code 8”, “Code 11”, “Dry Run - Canceled Enroute”, "Dry Run - UTL
Incident", "Public Assist" and "Station Coverage" are specific selections
made by the user.
I need the query to single out all of the records that do not have "Code 8”,
“Code 11”, “Dry Run - Canceled Enroute”, "Dry Run - UTL Incident", "Public
Assist" and "Station Coverage" in CallDetails.

--
Message posted via http://www.accessmonster.com

  #7  
Old January 7th, 2008, 03:20 AM posted to microsoft.public.access.forms
John W. Vinson
external usenet poster
 
Posts: 18,261
Default Query Group By Criteria

On Mon, 07 Jan 2008 01:51:32 GMT, "pushrodengine via AccessMonster.com"
u36225@uwe wrote:

I need the query to single out all of the records that do not have "Code 8,
Code 11, Dry Run - Canceled Enroute, "Dry Run - UTL Incident", "Public
Assist" and "Station Coverage" in CallDetails.


In that case a criterion of

NOT IN("Code 8, Code 11, Dry Run - Canceled Enroute, "Dry Run - UTL
Incident", "Public Assist", "Station Coverage")

will do the job. I thought you meant that CallDetails was a larger field
containing (or not) one of these as a substring... sorry for the
misinterpretation!


John W. Vinson [MVP]
  #8  
Old January 7th, 2008, 05:42 AM posted to microsoft.public.access.forms
pushrodengine via AccessMonster.com
external usenet poster
 
Posts: 106
Default Query Group By Criteria

Great!
Works like a Charm!

Thank You.

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...forms/200801/1

 




Thread Tools
Display Modes

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 Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 10:55 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright 2004-2024 OfficeFrustration.
The comments are property of their posters.