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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Report with Multiple Criteria

Status
Not open for further replies.

stru

Programmer
Mar 23, 2002
10
US
Hi,

I have a report that is currently being generated based on 3 different selection criteria. I have created a form where the info is entered and passes the criteria along to the report. It works fine.

I would like to add an additional 2 fields for criteria. The problem I am having is the code I created will be too long with 5 criteria. Here is the code with the 3 criteria that currently works

SELECT tblArchive.Date1, tblArchive.DMM, tblArchive.Department, tblArchive.PDNo, tblArchive.SKU, tblArchive.ItemDescription, tblArchive.FirstCost, tblArchive.SuggestedRetail, tblArchive.Product, tblArchive.IMU, tblArchive.ELC, tblArchive.LandingFactor, tblArchive.LandingCosts, ([tblArchive].[Date1]) Between [Forms]![frmDates]![txtSD] And [Forms]![frmDates]![txtED] AS Expr1 FROM tblArchive WHERE (((tblArchive.Date1) Between [Forms]![frmDates]![txtSD] And [Forms]![frmDates]![txtED]) AND ((tblArchive.DMM)=[Forms]![frmDates]![cboDMM]) AND ((tblArchive.Department)=[Forms]![frmDates]![cboDpt])) OR (((tblArchive.Date1) Between [Forms]![frmDates]![txtSD] And [Forms]![frmDates]![txtED]) AND ((tblArchive.DMM)=[Forms]![frmDates]![cboDMM]) AND (([Forms]![frmDates]![cboDpt]) Is Null)) OR (((tblArchive.Date1) Between [Forms]![frmDates]![txtSD] And [Forms]![frmDates]![txtED]) AND ((tblArchive.Department)=[Forms]![frmDates]![cboDpt]) AND (([Forms]![frmDates]![cboDMM]) Is Null)) OR (((tblArchive.DMM)=[Forms]![frmDates]![cboDMM]) AND ((tblArchive.Department)=[Forms]![frmDates]![cboDpt]) AND ((([tblArchive].[Date1]) Between [Forms]![frmDates]![txtSD] And [Forms]![frmDates]![txtED]) Is Null) AND (([Forms]![frmDates]![cboDpt]) Is Null)) OR (((tblArchive.DMM)=[Forms]![frmDates]![cboDMM]) AND ((([tblArchive].[Date1]) Between [Forms]![frmDates]![txtSD] And [Forms]![frmDates]![txtED]) Is Null)) OR (((tblArchive.Department)=[Forms]![frmDates]![cboDpt]) AND ((([tblArchive].[Date1]) Between [Forms]![frmDates]![txtSD] And [Forms]![frmDates]![txtED]) Is Null) AND (([Forms]![frmDates]![cboDMM]) Is Null)) OR (((tblArchive.Date1) Between [Forms]![frmDates]![txtSD] And [Forms]![frmDates]![txtED]) AND (([Forms]![frmDates]![cboDpt]) Is Null) AND (([Forms]![frmDates]![cboDMM]) Is Null));

I realize that this is inefficient, but I just tried to do what works. I need some code that will allow the report to be based on the 5 criteria and not just the 3. Does anyone have a suggestion as to how I should/could go about this? Thanks.
 
This may help:
Build Report Criteria via a Form w/list box, text box, date range
faq181-5497
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top