Handling nulls in a query?

kdirvin

Registered User.
Local time
Today, 04:50
Joined
Feb 13, 2011
Messages
41
My 2007 database stores projects and the contracts on which they go. Each contract has several options, one for each fiscal year that the contract spans. Here is my table structure:
Tbl_FiscalYear (lookup for fiscal years)
FiscalYearID
FiscalYear

Tbl_Projects
ProjectID
ProjectName
ProjectFiscalYearFK

Tbl_Contracts
ContractID
ContractNumber

Tbl_ContractOptions
OptionID
ContractNumberFK
OptionStart (date type field)
OptionStartFiscalYearFK

My query has fields FiscalYear (from lookup table tbl_FiscalYear), ProjectName, ContractNumber, and OptionStart. I have set a parameter [Enter the fiscal year] in the criteria row of FiscalYear because the user will run the query for one FY at a time. Through the relationships between FiscalYear, ProjectFYFK, and OptionStartFYFK, setting a parameter for the FiscalYear field should return the values for ProjectName and OptionStart that correspond to the chosen fiscal year.

The problem is that both the OptionStart and OptionStartFiscalYearFK fields must contain null values. By setting a parameter for FiscalYear, the query excludes the nulls, and the projects and contracts attached to those records with null values do not show.

To handle the nulls, I tried entering
[Enter the fiscal year] Or Is Null
into the Criteria row of FiscalYear field, but the query is still excluding those records with null values.
I then tried splitting the single query into two queries to create an outer join. In the two queries setup, I set two parameters, one each for ProjectFiscalYearFK and for OptionStartFYFK. Null values were still excluded.

Clearly I do not understand how to properly handle nulls here. Any help would be appreciated!
Thanks!
 
So you want to select

Where projectfyfk = fiscalyear or projectfyfk is null

I think that you can only do this with the where clause and no join


Brian
 
Hi Brian,

So you're saying that I should not be doing an outer join? Sorry for my dense question, just not sure what you meant by your answer!

Thanks!
 

Users who are viewing this thread

Back
Top Bottom