PMFJI,
The IIF() statement reformatted looks like:
Code:
ErrorCode1:
IIf(
[Payment in Full Stop Code]=0
And [EscrowMTH]>0 And[Days Delinquent]<90
And DateAdd("m",12,[LAST ESCROW ANALYSISDATE])<[Report Date]
And DateAdd("m",12,[NOTE DATE])<[First DueDT]
And [FORECLOSURE STOPS]<>7
Or
[Payment in Full Stop Code]=0
And[EscrowMTH]>0 And [Days Delinquent]<90
And DateAdd("m",12,[LASTESCROW ANALYSIS DATE])<[Report Date]
And DateAdd("m",12,[NOTEDATE])<[First Due DT]
And [FORECLOSURE STOPS]<>8
Or
[Payment in FullStop Code]=0
And [EscrowMTH]>0 And [Days Delinquent]<90
And DateAdd("m",12,[LAST ESCROW ANALYSIS DATE])<[Report Date]
And DateAdd("m",12,[NOTE DATE])<[First Due DT]
And [FORECLOSURESTOPS]<>9,
1,
0)
In the VBA Order of Operations, "AND" has a higher Order than "OR" so "AND"s are grouped first then "Or"s.
I would have used parenthesis to clarify the order.......
You stated:
Above is my code. The criteria is below.
Does not have Foreclosure Stop 7,8,9 or is not past due greater than 90days. Loan has escrow, and is also not a new loan booked within the past1 year.
I'm not sure about your criteria, but the query column might be written:
Code:
ErrorCode1:
IIf(
(
([FORECLOSURE STOPS]<>7 AND [FORECLOSURE STOPS]<>8 AND [FORECLOSURE STOPS]<>9)
OR
[EscrowMTH]>0 And[Days Delinquent]<90
)
AND [Payment in Full Stop Code]=0
And [EscrowMTH]>0 And[Days Delinquent]<90
And DateAdd("m",12,[LAST ESCROW ANALYSISDATE])<[Report Date]
And DateAdd("m",12,[NOTE DATE])<[First DueDT],
1,
0)
without the formatting, it would be
Code:
ErrorCode1:
IIf((([FORECLOSURE STOPS]<>7 AND [FORECLOSURE STOPS]<>8 AND [FORECLOSURE STOPS]<>9) OR [EscrowMTH]>0 And[Days Delinquent]<90) AND [Payment in Full Stop Code]=0 And [EscrowMTH]>0 And[Days Delinquent]<90 And DateAdd("m",12,[LAST ESCROW ANALYSISDATE])<[Report Date] And DateAdd("m",12,[NOTE DATE])<[First DueDT] ,1, 0)