Results 1 to 8 of 8
  1. #1
    Join Date
    Aug 2003
    Posts
    123

    Question Unanswered: Or clauses in Select Case

    Is it possible to use an Or clause in a Select Case block (or even advisable for that matter)? Just to make the block shorter since several cases would have the same logic. For instance:

    Select Case i
    Case 1 Or 2 Or 6 Or 8
    Case 3 Or 5 Or 9
    Case Else
    End Select

  2. #2
    Join Date
    Feb 2004
    Location
    Chicago, IL
    Posts
    1,312
    You should get familiar with the built in help. It will answer your question faster than someone here can. But to answer your question, use a comma to delimit the list of values, or if they are sequential then use the To key word. From help...

    Code:
    Function Bonus(performance, salary)
        Select Case performance
            Case 1
                Bonus = salary * 0.1
            Case 2, 3
                Bonus = salary * 0.09
            Case 4 To 6
                Bonus = salary * 0.07
            Case Is > 8
                Bonus = 100
            Case Else
                Bonus = 0
        End Select
    End Function

  3. #3
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    Agreed... the help in Access is pretty good... well... perhaps except for Access 2007.
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  4. #4
    Join Date
    Aug 2003
    Posts
    123
    Thanks. I only ask when the answer can't be found in Help.

  5. #5
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Quote Originally Posted by StarTrekker
    Agreed... the help in Access is pretty good... well... perhaps except for Access 2007.
    Oh lord - it has got worse in 2k7? 2k was brill. I think that 2k2 was poor IIRC. 2k3 is awful. BoL is just sublime - it should be the model for ALL MS help files.
    Testimonial:
    pootle flump
    ur codings are working excelent.

  6. #6
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    BoL?

    Agreed that 2000's help is great... 97 was pretty good too.

    In 2007, if you search for something, or press F1 when the cursor is on a keyword you will very often be confronted first up with a screen that shows you multiple identical entries to click on, like 25 "Format" entires... and no way of determining which is the correct one to click on. And the guessing game begins. I hate it.
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  7. #7
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    BoL = Books OnLine (SQL Server help\ manual).
    Testimonial:
    pootle flump
    ur codings are working excelent.

  8. #8
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    Oh.. of course.
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •