Criteria for table query & 5 tables

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need to build a query to either open a report or build a table that will
open the report, not sure which way to do this.

I have a main table (tblEpistry) and 4 unit tables (tblUnit1 through
tblUnit4).

I need to look at 2 fields in each tblUnit#, [CAMT] and [FORM2], if either
or both are blank, then I need that row.

Because each row in the tblEpistry has a Yes/No field to indicate if there
is data for the corresponding tblUnit#, there could be up to four rows from
the unit tables.

My question is, how would I build the criteria in the query to ensure I
catch each unit row that has a blank CAMT or FORM2 field?

Thanks in advance for any assistance.
 
The first query either CAMT OR FORM2 being null the record is selected.
SELECT BB, CAMT, FORM2
FROM tblUnit1
WHERE [CAMT] Is Null OR [FORM2] Is Null
UNION SELECT BB,CAMT,FORM2
FROM tblUnit2
WHERE [CAMT] Is Null OR [FORM2] Is Null
UNION SELECT BB,CAMT, FORM2
FROM tblUnit3
WHERE [CAMT] Is Null OR [FORM2] Is Null
UNION SELECT BB,CAMT, FORM2
FROM tblUnit4
WHERE [CAMT] Is Null OR [FORM2] Is Null;

This query both CAMT and FORM2 must be null to be selected.
SELECT BB, CAMT, FORM2
FROM tblUnit1
WHERE [CAMT] Is Null AND [FORM2] Is Null
UNION SELECT BB,CAMT,FORM2
FROM tblUnit2
WHERE [CAMT] Is Null AND [FORM2] Is Null
UNION SELECT BB,CAMT, FORM2
FROM tblUnit3
WHERE [CAMT] Is Null AND [FORM2] Is Null
UNION SELECT BB,CAMT, FORM2
FROM tblUnit4
WHERE [CAMT] Is Null AND [FORM2] Is Null;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top