View Full Version : Else If help


tmaleski
04-28-2009, 07:37 AM
// This adjusts the paper size based upon the standard paper sizes
if RoundUp ({argReportsEx.HeightImperial}, 0) < 25 then
if RoundUp ({argReportsEx.WidthImperial},0 )< 9 then 8
else if RoundUp ({argReportsEx.WidthImperial},0 ) < 10 then 9
else if RoundUp ({argReportsEx.WidthImperial},0 ) < 12 then 11
else if RoundUp ({argReportsEx.WidthImperial},0 ) < 13 then 12
else if RoundUp ({argReportsEx.WidthImperial},0 ) < 19 then 18
else if RoundUp ({argReportsEx.WidthImperial},0 ) < 25 then 24
else 30

I get an error msg "While attempting to display the report, the following error occurred: Anumber, currency... is expected here......."

PeterOC
04-30-2009, 05:39 AM
Does it indicate where the number / currency is expected?

One thing that looks a bit strange is that there's no number at the end of line 2.

Peter

MSAccessRookie
04-30-2009, 06:31 AM
// This adjusts the paper size based upon the standard paper sizes
if RoundUp ({argReportsEx.HeightImperial}, 0) < 25 then
if RoundUp ({argReportsEx.WidthImperial},0 )< 9 then 8
else if RoundUp ({argReportsEx.WidthImperial},0 ) < 10 then 9
else if RoundUp ({argReportsEx.WidthImperial},0 ) < 12 then 11
else if RoundUp ({argReportsEx.WidthImperial},0 ) < 13 then 12
else if RoundUp ({argReportsEx.WidthImperial},0 ) < 19 then 18
else if RoundUp ({argReportsEx.WidthImperial},0 ) < 25 then 24
else 30

I get an error msg "While attempting to display the report, the following error occurred: Anumber, currency... is expected here......."

I am not exactly sure why you have this error, but with this many Else If Statements in your code, you may want to consider using Select/Case Statements instead.

tmaleski
04-30-2009, 06:21 PM
Thank you for the help.

No number after line two, I want a nested if statement

Case function, can you give an example?

MSAccessRookie
05-01-2009, 06:44 AM
Thank you for the help.

No number after line two, I want a nested if statement

Case function, can you give an example?

The format for Select/Case is similar to the following (remember that you need to substitute as required:

Select(SomethingtoSelect}
Case {Condition or Range1}:
Action to take

Case {Condition or Range2}:
Action to take
.
. {More Cases go here}
.
Default: {Condition or Range}
Action to take


In your case the Inner If Statement would look something like:


Select RoundUp ({argReportsEx.WidthImperial},0 )
Case < 9:
8

Case < 10:
9
.
. {The rest of the Cases go here}
.
Default:
30