Access query help

Joined
Jun 22, 2011
Messages
24
I'm not sure if this can be done, but any help would be appreciated. I've created a query in access with about 10 columns.

The first column is the key that combines the tables, and then the other 9 columns ihave null or not null values.

What I need to do is pull all the records with atleast one column value. For example, the first result could have a value in column 2, and no values in any other columns. The second result could have a value in column 3, but no other values etc. I'm finding it difficult to ge these results using the "and" "or" criteria method.

Thanks again!
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
I came up with this:

Code:
SELECT *
FROM Table1
WHERE
Len(
 NZ([F2]) & Nz([F3]) & Nz([F4]) &  
 Nz([F5]) & Nz([F6]) & Nz([F7]) & 
 Nz([F8]) & Nz([F9]) & Nz([F10])
 )>0;

It's not exactly pretty but should do the trick. Be sure to keep a space on both sides of each & character so that Access correctly interprets the concatenation operator (though probably this is a habit I have from VBA that isn't an issue in SQL statements). We skipped Field 1 on the assumption that the ID field is required and therefore always has a value.
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,329
Members
452,635
Latest member
laura12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top