PC Review


Reply
Thread Tools Rate Thread

6 Field Query

 
 
andy.s@yourplaceabroad.com
Guest
Posts: n/a
 
      13th Dec 2006
For some reason I can't get my head round this so any help is much
appreciated!

I want to create a query based on 6 fields. I want the query to include
the record if more than 1 of the fields is not null.

Therefore if 2 of those fields contain a value include the record, if 6
of the fields contain a value include the record, if 1 of the fields
contains a value do not return the record.

 
Reply With Quote
 
 
 
 
Brendan Reynolds
Guest
Posts: n/a
 
      13th Dec 2006

SELECT tblTest.*
FROM tblTest
WHERE
(((IIf(IsNull([Field1]),0,1)+IIf(IsNull([Field2]),0,1)+IIf(IsNull([Field3]),0,1)+IIf(IsNull([Field4]),0,1)+IIf(IsNull([Field5]),0,1)+IIf(IsNull([Field6]),0,1))>1));

This isn't very efficient, as the database engine will not be able to make
use of any indexes on those fields. There could be performance problems if
there are large numbers of records involved.

--
Brendan Reynolds
Access MVP

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> For some reason I can't get my head round this so any help is much
> appreciated!
>
> I want to create a query based on 6 fields. I want the query to include
> the record if more than 1 of the fields is not null.
>
> Therefore if 2 of those fields contain a value include the record, if 6
> of the fields contain a value include the record, if 1 of the fields
> contains a value do not return the record.
>



 
Reply With Quote
 
andy.s@yourplaceabroad.com
Guest
Posts: n/a
 
      13th Dec 2006
Thanks Brendan, works a treat on 10,000 records.

It was one of those things that was making my head hurt!

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Memo field is automatically changing to text field in count query robert Microsoft Access 3 3rd Dec 2008 09:27 PM
How to load a field control source from a query or form field valu Marco Microsoft Access Reports 0 24th Mar 2008 12:29 PM
How to display Table Field names AND Field Definitions in a Report ? (ditto for query fields & criteria) Will Microsoft Access 1 29th Aug 2007 01:14 PM
Select Query - Show field that is greater than differnet field =?Utf-8?B?SmFtZXMgTw==?= Microsoft Access 1 12th Dec 2005 09:40 PM
Text box in field doesn't return same info as in query field it's based on denilynn Microsoft Access Forms 9 3rd Mar 2004 06:42 PM


Features
 

Advertising
 

Newsgroups
 


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