Case statement not working?? Help please

C

cormier35

Using Access 2003 SP3
I'm running debug and when f is > 259 (3rd and 4th case), 2nd case keeps
getting calculated.

Select Case f
Case Is < 10
RE102_Spec = 56
Case Is >= 10 <= 259
RE102_Spec = 56 + 20 * Log10(f / 10)
Case Is > 259 < 10000
RE102_Spec = 46 + 18 * Log10(f / 259)
Debug.Print f; ", " & RE102_Spec
Case Is >= 10000
RE102_Spec = 76
End Select
Debug.Print f; "* " & RE102_Spec
 
K

KC-Mass

Don't you need a "AND" or "OR" between the two exprssions like:

Case Is >= 10 AND Is <= 259

Regards
 
M

Mr. B

Hi, cormier35.

Try this:

Select Case F
Case Is < 10
RE102_Spec = 56
Case 10 To 259
RE102_Spec = 56 + 20 * Log10(F / 10)
Case 260 To 999
RE102_Spec = 46 + 18 * Log10(F / 259)
Debug.Print F; ", " & RE102_Spec
Case Is >= 10000
RE102_Spec = 76
End Select

You need to use the "To" connector to check between two values.
 
S

Stuart McCall

KC-Mass said:
Don't you need a "AND" or "OR" between the two exprssions like:

Case Is >= 10 AND Is <= 259

Nope, you need to use a comma:

Case Is >= 10, Is <= 259
 
C

cormier35 via AccessMonster.com

Thanks soooo much, yes, yours worked and I tried the To expression but did
not drop the Is!!

Mr. B said:
Hi, cormier35.

Try this:

Select Case F
Case Is < 10
RE102_Spec = 56
Case 10 To 259
RE102_Spec = 56 + 20 * Log10(F / 10)
Case 260 To 999
RE102_Spec = 46 + 18 * Log10(F / 259)
Debug.Print F; ", " & RE102_Spec
Case Is >= 10000
RE102_Spec = 76
End Select

You need to use the "To" connector to check between two values.

-----
HTH
Mr. B
askdoctoraccess dot com
Using Access 2003 SP3
I'm running debug and when f is > 259 (3rd and 4th case), 2nd case keeps
[quoted text clipped - 12 lines]
End Select
Debug.Print f; "* " & RE102_Spec
 
J

Jack Leach

Nope, you need to use a comma:
Case Is >= 10, Is <= 259

I was just working up a Case statement the other day, and had to stop and
stratch my head because I've never put more than one condition on a line
before. I ended up using an If/Then/Else instead because I didn't think it
could be done.

Nice Tip.

Mr.B's as well.

--
Jack Leach
www.tristatemachine.com

"I haven't failed, I've found ten thousand ways that don't work."
-Thomas Edison (1847-1931)
 
D

Dale_Fye via AccessMonster.com

Actually, since the case statements are processed in order, you could use:

Select Case f
Case < 10
Case <= 259
Case <= 10000
Case > 10000
Case Else
End Select
 
D

Dale_Fye via AccessMonster.com

Actually, since the case statements are processed in order, you could use:

Select Case f
Case < 10
Case <= 259
Case <= 10000
Case > 10000
Case Else
End Select
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top