I have two snippets of code used in Microsoft Access 2003 VBA. It takes and integer and checks to see if it is in one of five groups; less than 2, =2, 3 or 4, and 5 or greater. Using IF-THEN-ELSE works, but Select case doesn't!
Here are the snippets:
' age_chk is an integer
' AgeGroup is a variant
' This one works...
if age_chk < 2 then
AgeGroup = 1
else if age_chk = 2
AgeGroup = 2
else if age_chk = 3 then
AgeGroup = 3
else if age_chk = 4 then
AgeGroup = 4
Else AgeGroup = 5
end if
' This one doesn't...
Select Case age_chk
Case age_chk < 2
AgeGroup = 1
Case age_chk = 2
AgeGroup = 2
Case age_chk = 3
AgeGroup = 3
Case age_chk = 4
AgeGroup = 4
Case Else
AgeGroup = 5
End Select
' end snippets