Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combine Criteria's on single Query 1

Status
Not open for further replies.

summer01

Technical User
Jan 28, 2008
19
US
I have been trying to figure out how to combine criteria/expression without creating another query. I was wondering if this can be done. I need to see all records (open and closed) for the current and previous year as well as records for other years that are null in the Date Closed field.
I have created a field (YEAR)from my Date Opened and set the criteria asking for records for the current year and the previous year. This all works fine. I am having problems with the null records in the Date closed field. Below is my SQL.

SELECT Table1.ID, Year([Date Opened]) AS [Year], Table1.[Date Opened], Table1.[Date Closed], Table1.PIN, Table1.Department, Table1.System, Table1.LOB, Table1.Responsible, Table1.[PID #], Table1.[BCR #], Table1.[MA Inquiry #], Table1.Issue, Table1.Activity, Table1.Resolution, Table1.[Control Plan], Table1.[Provider Type], Table1.Source, Table1.Product, Table1.[Procedure/HCPCS], Table1.TOS, Table1.POS, Table1.Modifiers, Table1.RevCode, Table1.[NP Code], Table1.Group, Table1.Recovery, Table1.Other, Table1.[Recv No], Table1.[Process Key], Table1.ErrId, Table1.Workaround, Table1.DocICN, Table1.DOS, Table1.ContractNum
FROM Table1
WHERE (((Year([Date Opened])) Between Year(Date())-1 And Year(Date())))
ORDER BY Table1.ID DESC;
 
How about:

Code:
<...>
WHERE Year([Date Opened]) Between Year(Date())-1 And Year(Date()) Or [Date Closed] Is Null
<...>

As an aside, it is always best to avoid spaces in field and control names, it will save you hours of grief. Most symbols (eg #) should also be avoided, anything, infact, that means you must use square brackets []

 
Sorry for the late thanks but just got back from holiday visit and didn't have my computer with me. Your help gave me what I was looking for and I do appreciate your good advice as well. Its an easy concept to remember and I will do that.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top