INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

how do I???

how do I???

(OP)
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:
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")))  the Nz doesn't return any errors or records
 

=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"))) everything goes in active even though sortgrp has them as retired

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 
on the report group header, if I spell everything out, then I run into to many characters errors

RE: how do I???

If I follow you should have a complicated nested series of IIF to get to your groups and return field. Then sort by that column in your report.

RE: how do I???

(OP)
I ended up putting the code in the query.

qry columns:
[Enter Report Start Date]
[Enter Report End Date]

SrtGrp: SortGrp: IIf([SortGrp2]="Active WH",1,IIf([SortGrp2]="Active Other",2,IIf([SortGrp2]="Retired WH",3,4)))

SrtGrp2: SortGrp2: Switch(Mid([t_PermitAccounts].[PermitNo],1,2)='WH' And ([t_HaulerVehicles].[EffectiveDate] Between [Report Start Date] And [Report End Date]) And ([t_HaulerVehicles].[RetireDate]<=[Report End Date]),'Retired WH',Mid([t_PermitAccounts].[PermitNo],1,2)<>'WH' And ([t_HaulerVehicles].[EffectiveDate] Between [Report Start Date] And [Report End Date]) And ([t_HaulerVehicles].[RetireDate]<=[Report End Date]),'Retired Other',Mid([t_PermitAccounts].[PermitNo],1,2)='WH' And ([t_HaulerVehicles].[EffectiveDate] Between [Report Start Date] And [Report End Date]) And ([t_HaulerVehicles].[RetireDate]>[Report End Date]),'Active WH',Mid([t_PermitAccounts].[PermitNo],1,2)<>'WH' And ([t_HaulerVehicles].[EffectiveDate] Between [Report Start Date] And [Report End Date]) And ([t_HaulerVehicles].[RetireDate]>[Report End Date]),'Active Other')

Then I used SrtGrp as the report group header. In the Group Header Area I put a label: =IIf([SortGrp]=1,"ADDITIONS TO PERMITTED WASTE HAULERS",IIf([SortGrp]=2,"ADDITIONS TO BUSES/OTHER",IIf([SortGrp]=3,"RETIRED PERMITTED WASTE HAULERS","RETIRED BUSES/OTHER")))

Works very nice. Thanks for all the help

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close