Solved

Between values in a SELECT CASE vba statement

Posted on 2013-01-17
5
751 Views
Last Modified: 2013-01-17
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
Comment
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
  • Learn & ask questions
5 Comments
 
LVL 66

Expert Comment

by:Jim Horn
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

by:
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

by:hnasr
ID: 38789131
Upload a sample database.
Type the expected output.
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 38789196
how did you declare varScore ?
it should be declared as double to recognize the decimal values


dim varScore as double

or in your function

function whatever(varScore as double)
0
 

Author Closing Comment

by:ssmith94015
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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

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

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question