dbTalk Databases Forums  

Establish When Multiple Fields Are True/False -1/0 Yes/No From A Query

comp.databases.ms-access comp.databases.ms-access


Discuss Establish When Multiple Fields Are True/False -1/0 Yes/No From A Query in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
bezz
 
Posts: n/a

Default Establish When Multiple Fields Are True/False -1/0 Yes/No From A Query - 10-18-2010 , 05:06 PM






I have a table which has multiple flags set for various eventand can be true or false.

The table is constructed along the lines of


FieldName Record 1 Record 2 Record 3
Section Alpha Bravo Charlie
DocumentName Transcript137 Transcript145 Transcript189
RequiredForEventA True False False
RequiredForEventB False False False
RequiredForEventC False False False
RequiredForEventD False True False
RequiredForEventE False False False
RequiredForEventF False False False
RequiredForEventG False False False
RequiredForEventH False True False


Etc...


In the example above, I only want to pull out Record 3 as Section Charlie and Transcript 189 entries are all False.

I relaise this can be done by using a Union Query and adding records to the selection of the flag is false, and also using and IIF() function, the only problem being neither solution
is particularly elegant.

Has anyone found a simple way to check that all specified flags in the record are False?

Thanks

J


--
--------------------------------- --- -- -
Posted with NewsLeecher v3.9 Final
Web @ http://www.newsleecher.com/?usenet
------------------- ----- ---- -- -

Reply With Quote
  #2  
Old   
Bob Barrows
 
Posts: n/a

Default Re: Establish When Multiple Fields Are True/False -1/0 Yes/No From A Query - 10-18-2010 , 05:49 PM






bezz wrote:
Quote:
I have a table which has multiple flags set for various eventand can
be true or false.

The table is constructed along the lines of


FieldName Record 1 Record 2 Record 3
Section Alpha Bravo Charlie
DocumentName Transcript137 Transcript145
Transcript189
RequiredForEventA True False False
RequiredForEventB False False False
RequiredForEventC False False False
RequiredForEventD False True False
RequiredForEventE False False False
RequiredForEventF False False False
RequiredForEventG False False False
RequiredForEventH False True False


Etc...


In the example above, I only want to pull out Record 3 as Section
Charlie and Transcript 189 entries are all False.

I relaise this can be done by using a Union Query and adding records
to the selection of the flag is false, and also using and IIF()
function, the only problem being neither solution is particularly
elegant.

Has anyone found a simple way to check that all specified flags in
the record are False?

As you've discovered, this is not the ideal design for the question you are
asking. And probably for most questions that will be asked as well

There should be one T/F field. The rest of the fields should describe what
is either true or false. Something like:

Section DocumentName Event Required
Alpha Transcript137 A True
Alpha Transcript137 B False
etc

Rule of thumb:
databases: narrow and long
spreadsheets: wide and short

If you cannot modify this table's design for some reason, then you have to
get the data into this format. I would use a union query (I think you
alluded to this) to create a saved query (a view) called
RequiredEventsFolded, like this:

SELECT Section DocumentName, "A" As Event,RequiredForEventA As Required
UNION ALL
SELECT Section DocumentName, "B" As Event,RequiredForEventB As Required
UNION ALL
....

Now, your question is easily answered by a grouping query:

Select Section, DocumentName
FROM RequiredEventsFolded
GROUP BY Section, DocumentName
HAVING MIN([Required]) = False

Reply With Quote
Reply




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



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.