Results 1 to 3 of 3
  1. #1
    4 Star Lounger
    Join Date
    Jun 2001
    Posts
    531
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Select case (97)

    Select case
    I wrote the below but the second case does not execute for something like say, 1201. I was hoping for any insight. Please advise. This fragment appears in the format event of a header of a report grouped upon code.

    Select Case code
    'directors & sal coord...
    Case 1100, 1200, 1300, 1400, 1500
    Me.RegionDescription = DLookup("regionDescription", "Region", "code=" & code)
    'managers...
    Case Not (Right(code, 2)) = 99, Not (Right(code, 2)) = "00", Not (code) > 1599
    Me.RegionDescription = DLookup("regionDescription", "Region", "code=" & code)
    'others...
    Case Is > 1599

    End Select

  2. #2
    3 Star Lounger
    Join Date
    Dec 2000
    Location
    USA
    Posts
    379
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Select case (97)

    Well, it didn't work for me that way either, but if I dimmed a variable to hold the value of the Right() expression and then used that variable as the Select Case test, it worked fine. Must be something about using that function within the Select Case.

    This may mean you have to split the code into seperate decision statements since sometimes you are testing all of the value and sometimes only a portion of it, but it's the only way I could get it to work. Someone elsse may know more about this.

  3. #3
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Select case (97)

    A Select Case takes an expression and uses that as the basis for conditional execution. Since you're looking at the value of the code, it doesn't make sense to try to manipulate that value in a case. Try this instead:

    Select Case code

    'directors & sal coord...
    Case 1100, 1200, 1300, 1400, 1500
    Me.RegionDescription = DLookup("regionDescription", "Region", "code=" & code)

    'others...
    Case Is > 1599
    'whatever goes here

    Case Else
    'managers...
    If (Right(code, 2)) <>"99" And Not (Right(code, 2)) <>"00" Then
    Me.RegionDescription = DLookup("regionDescription", "Region", "code=" & code)
    End If



    End Select
    Charlotte

Posting Permissions

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