Solved

# Between values in a SELECT CASE vba statement

Posted on 2013-01-17
751 Views
Have an ACCESS 2003 function taht, based on the value passed in, should return a string.  However, I think it is not recognizing the between statement.

Sandra

Select Case varScore
Case  0 To 1.749
fntRankings = "Unacceptable"
Case 1.74901 To 2.999
fntRankings "Does Not Meet"
Case 3# To 3.749
fntRankings "Meets"
Case 3.7491 To 4.249
fntRankings "Meets Plus"
Case 4.2491 To 4.749
fntRankings "Exceeeds"
Case 4.7491 To 5#
fntRankings "Outstanding"
Case Else
fntRankings "Unknown"
End Select
0
Question by:ssmith94015
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points

LVL 66

Expert Comment

ID: 38789073
(1)  Is the # a typo?
(2)  What does the fnt stand for?   In one line (0 To 1.749) you're setting it to a string, in others you have a string as a parameter, which means it's not setting it to that string.
0

LVL 48

Accepted Solution

Dale Fye earned 500 total points
ID: 38789125
You might want to consider putting these values in a table, rather than code.  That would facilitate the use of a DLOOKUP.  The table would look like:

LTE          GT            Ranking
0             1.749         Unacceptable
1.749      2.999         Does Not Meet
2.999      3.749         Meets
3.749      4.249         Meets Plus
4.249      4.749         Exceeeds
4.749      5.0             Outstanding
5.0          NULL         Unknown

Then, you could use a DLOOKUP like:

=DLOOKUP("Ranking", "YourTable", "[LTE] <= " & TestValue & " AND [GT] > " & TestValue)

This method provides you with the flexibility of modifying your upper and lower values associated with each ranking without having to rewrite your code.
0

LVL 30

Expert Comment

ID: 38789131
Type the expected output.
0

LVL 120

Expert Comment

ID: 38789196
how did you declare varScore ?
it should be declared as double to recognize the decimal values

dim varScore as double

function whatever(varScore as double)
0

Author Closing Comment

ID: 38789508
fntRanking is actually the function name and there is already a table which I can now capitalize on.  Thank you for pointing that out!

The # sign was for whatever reason added when I ran the function, don't know why.

Sandra
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
###### Suggested Courses
Course of the Month8 days, 11 hours left to enroll