Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Between values in a SELECT CASE vba statement

Posted on 2013-01-17
5
Medium Priority
?
754 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 2000 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 31

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

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

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

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

718 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