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

Multiple IF, Then, Elseif and Or criteria 1

Status
Not open for further replies.

Eprice

Technical User
May 6, 2003
209
US
Hi,
I need to make different criteria depending on the current month. The report I have set up for every month, no matter what month it is has this code.
(
{joblog_.FREQUENCY} = "MONTHLY" and
INSTR({Joblog_.DISTRIBUTION}, "AC") <> 0 and
{Joblog_.DISTRIBUTION}<>"AC/TW" and
{Joblog_.JOBNAME}<>"" and
(
Ucase(totext(CurrentDate,"MMM")) in {joblog_.FREQUENCY DETAIL} OR
{joblog_.FREQUENCY DETAIL} = "REQUEST" OR
{joblog_.FREQUENCY DETAIL} = "NONE"
)
)
or
(
{joblog_.FREQUENCY} = "SPECIAL" and
INSTR({Joblog_.DISTRIBUTION}, "AC") <> 0 and
{Joblog_.DISTRIBUTION}<>"AC/TW" and
{Joblog_.JOBNAME}<>"" and
(

Ucase(totext(CurrentDate,"MMM")) in {joblog_.FREQUENCY DETAIL} OR
{joblog_.FREQUENCY DETAIL} = "REQUEST" OR
{joblog_.FREQUENCY DETAIL} = "NONE"
)
)
or
(
{joblog_.FREQUENCY} = "DAILY" and
INSTR({Joblog_.DISTRIBUTION}, "AC") <> 0 and
{Joblog_.DISTRIBUTION}<>"AC/TW" and
{Joblog_.JOBNAME}<>""
)
or
(
{joblog_.FREQUENCY} = "WEEKLY" and
INSTR({Joblog_.DISTRIBUTION}, "AC") <> 0 and
{Joblog_.DISTRIBUTION}<>"AC/TW" and
{Joblog_.JOBNAME}<>""
)

What I need to do is add to the above - if the current month is a quarterly month, semi annual or annual. Say if it is March, June, September or December I would need to add a part for joblog_.Frequency = Quarterly.

June would also contain a part for SemiAnnual and December would contain a part for SemiAnnual and Annual.

I think using IIf, Else, ElseIF would work but don't know how to do it with so many "or" in the code I already have. I could always make 12 reports but don't want to do that. If I can get some help on June, I can probably figure out the semiannual and annual. Please help.
Lisa
 
EPrice,

For clarity, the above code is needed in addition to something to Quarter-ends, Semi-Annual and Annual, or the "Monthly" part of the above needs to be modified for each of the listed scenarios?

If it is "more" criteria in addition to what is listed, I think you could wrap your entire criteria in parathesis and add the new criteria for Quarters, Semi-Annual & Annual amounts with an "AND" clause and go from there. If this is true, I think the following should work as a starting point (assuming I have understood correctly).

Note: your existing code is in black, additions are red
Code:
(
{joblog_.FREQUENCY} = "MONTHLY" and
INSTR({Joblog_.DISTRIBUTION}, "AC") <> 0 and
{Joblog_.DISTRIBUTION}<>"AC/TW" and
{Joblog_.JOBNAME}<>"" and
(
Ucase(totext(CurrentDate,"MMM")) in {joblog_.FREQUENCY DETAIL} OR 
{joblog_.FREQUENCY DETAIL} = "REQUEST" OR
{joblog_.FREQUENCY DETAIL} = "NONE"
) 
)
or
(
{joblog_.FREQUENCY} = "SPECIAL" and
INSTR({Joblog_.DISTRIBUTION}, "AC") <> 0 and
{Joblog_.DISTRIBUTION}<>"AC/TW" and
{Joblog_.JOBNAME}<>"" and
(

Ucase(totext(CurrentDate,"MMM")) in {joblog_.FREQUENCY DETAIL} OR
{joblog_.FREQUENCY DETAIL} = "REQUEST" OR
{joblog_.FREQUENCY DETAIL} = "NONE"
) 
)
or
(
{joblog_.FREQUENCY} = "DAILY" and
INSTR({Joblog_.DISTRIBUTION}, "AC") <> 0 and
{Joblog_.DISTRIBUTION}<>"AC/TW" and
{Joblog_.JOBNAME}<>"" 
)
or
(
{joblog_.FREQUENCY} = "WEEKLY" and
INSTR({Joblog_.DISTRIBUTION}, "AC") <> 0 and
{Joblog_.DISTRIBUTION}<>"AC/TW" and
{Joblog_.JOBNAME}<>"" 
)
[red]AND
(
IF Month(CurrentDate) in [3,6,9,12] THEN
(
  [green]//Your Criteria for Quarter Ends.[/green]
)
ELSE
IF Month(CurrentDate) in [6,12] THEN
(
  [green]//Your Criteria for Semi-Annual.[/green]
)
ELSE
IF Month(CurrentDate) in [12] THEN
(
  [green]//Your Criteria for Annual.[/green]
)
)[/red]

Hope this helps! Cheers!

Mike
---------------------------------------------------------------
"To be alive is to revel in the moments, in the sunrise and the sunset, in the sudden and brief episodes of love and adventure,
in the hours of companionship. It is, most of all, to never be paralyzed by your fears of a future that no one can foretell."
 
Thanks Mike, you post helped fix the report.
Lisa
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top