I have a query with a set of criteria. It's retrieving my data fine but now I have to take that data and sort it for the report. Not sure the best weay to handle it.
Here are the criteria.
query:
Prompted fields: ReportStart: [enter start date] ReportEnd: [enter end date]
Field: Effective Date:
Criteria:
Field: Retiredate
Criteria:
Field: left(PermitNo, 2) (WH or not WH)
I couldn't figure out how to set this note up as a table effect. the criteria lines should match up and
Lines 1 and 3 should be considered retired
Lines 2 and 4 should be considered active
What I need for a sort is:
If the left(PermitNo, 2) is WH and active, then group1
if the left(PermitNo, 2) is not WH and active then group 2
if the left(PermitNo, 2) is WH and retired, then group 3
if the left(PermitNo, 2) is not WH and retired the Group 4
on the report group header, if I spell everything out, then I run into to many characters errors
Here are the criteria.
query:
Prompted fields: ReportStart: [enter start date] ReportEnd: [enter end date]
Field: Effective Date:
Criteria:
1. <=[Report End Date] and >= [report start date]
2. <=[Report End Date] and >= [report start date]
3. <=[Report End Date] and >= [report start date]
4. <=[Report End Date] and >= [report start date]
Field: Retiredate
Criteria:
1. >[Report start Date]
2. isnull
3. <=[Report End Date] and >= [report start date]
4. >[Report End Date]
Field: left(PermitNo, 2) (WH or not WH)
I couldn't figure out how to set this note up as a table effect. the criteria lines should match up and
Lines 1 and 3 should be considered retired
Lines 2 and 4 should be considered active
What I need for a sort is:
If the left(PermitNo, 2) is WH and active, then group1
if the left(PermitNo, 2) is not WH and active then group 2
if the left(PermitNo, 2) is WH and retired, then group 3
if the left(PermitNo, 2) is not WH and retired the Group 4
Code:
on the report group header I've tried
=IIf(Left([PermitNo],2)="WH" And Nz([Retiredate],#12/31/2050#)>[reportend],"1",IIf(Left([PermitNo],2)<>"WH" And Nz([RetireDate],#12/31/2050#)>[ReportEnd],"2",IIf(Left([PermitNo],2)="WH" And Nz([RetireDate],#12/31/2050#)<=[ReportEnd],"3","4"))) [highlight #3465A4]the Nz doesn't return any errors or records[/highlight][highlight #FFFFFF][/highlight]
=IIF(Left([PermitNo],2)="WH" and sortGrp = "A", "1", IIF(Left([PermitNo],2)<>"WH" and sortGrp = "A", "2", iif(Left([PermitNo],2) <> "WH" and SortGrp = "A", "3", "4"))) [highlight #3465A4]everything goes in active even though sortgrp has them as retired[/highlight]
in the query I made another column
SortGrp: IIf(([effectivedate]<=[report end date] And [effectivedate]>=[report start date]) And [retiredate]>[report start date],"R",IIf(([effectivedate]<=[report end date] And [effectivedate]>=[report Start Date]) And ([retiredate]>=[Report Start Date] And [retiredate]<=[Report End Date]),"R",IIf(([effectivedate]<=[report end date] And [effectivedate]>=[report start date]) And IsNull([retiredate]),"A",IIf(([effectivedate]<=[report end date] And [effectivedate]>=[report start date]) And [retiredate]>[report end date],"A","oops")))) Everything comes out retired