IIf Statement not working.

  • Thread starter Thread starter Jason
  • Start date Start date
J

Jason

Hi,

This question was answered before in this newsgroup but
neither of the answers worked fully. I'm hoping to get a
revised answer.

Here is my question. How do I write a query or function
that will take

If Size >= Periods display "Dynamic", if not take Periods -
13 and perform Is Size >= Periods if yes
display "Dynamic2", if not take Periods - 13 again, then
perform is Size >= Periods, if yes display "Dynamic3", if
not take Periods - 13 again, etc

The statement I'm using is this:

DisplayValue: "Dynamic" & IIf([ChunkSize]>=[Number of
Periods],"",CStr$([Number of Periods]\13-[ChunkSize]
\13+2)))

It returns Dynamic4 when Periods=39 and Size=13 and when
Periods=48 and Size=22 (should be Dynamic3). Seems to get
hung up when the Size and Periods are the same after the
first iteration.

Thanks for any help.

Jason
 
Try

DisplayValue: "Dynamic" & IIf([ChunkSize]>=[Number of
Periods],"",CStr$(([Number of Periods]-1)\13))

([Number of Periods]-1) is to take into account when [Number of Periods] is
an exact multiple of 13 since your criteria is >=. Did you really want to
take away 13 everytime or did you want to take away [ChuckSize], if so just
change the 13 in the end of the equation to [ChunkSize].

Kelvin
 
Thanks Kelvin for the reply. Much appreciated.

Jason

-----Original Message-----
Try

DisplayValue: "Dynamic" & IIf([ChunkSize]>=[Number of
Periods],"",CStr$(([Number of Periods]-1)\13))

([Number of Periods]-1) is to take into account when [Number of Periods] is
an exact multiple of 13 since your criteria is >=. Did you really want to
take away 13 everytime or did you want to take away [ChuckSize], if so just
change the 13 in the end of the equation to [ChunkSize].

Kelvin

Hi,

This question was answered before in this newsgroup but
neither of the answers worked fully. I'm hoping to get a
revised answer.

Here is my question. How do I write a query or function
that will take

If Size >= Periods display "Dynamic", if not take Periods -
13 and perform Is Size >= Periods if yes
display "Dynamic2", if not take Periods - 13 again, then
perform is Size >= Periods, if yes display "Dynamic3", if
not take Periods - 13 again, etc

The statement I'm using is this:

DisplayValue: "Dynamic" & IIf([ChunkSize]>=[Number of
Periods],"",CStr$([Number of Periods]\13-[ChunkSize]
\13+2)))

It returns Dynamic4 when Periods=39 and Size=13 and when
Periods=48 and Size=22 (should be Dynamic3). Seems to get
hung up when the Size and Periods are the same after the
first iteration.

Thanks for any help.

Jason


.
 
Back
Top