Results 1 to 3 of 3
  1. #1
    Join Date
    May 2003
    Location
    UK
    Posts
    233

    Select Case Wildcard

    I am using the following code, using Basic Syntax. I want to use a wildcard in the code. Ie 5641****, 5642*** etc. Does anyone know if you can use a wildcard in a Select Case Statement and if so how is this done?

    Select Case ({@Expense Code})

    Case "56410000", "56420000", "56430000", "56440000", "56450000", "56460000", _
    "56580000", "56360000", "56370000", "56380000", "56390000", "56560000", _
    "56570000", "56580000", "56590000", "56410000", "56520000", "56530000"
    formula = "Admin & Clerical"

    Case "58330000", "5833NP09", "5833NP11", "5833NP12", "58350000"
    formula = "Admin & Clerical Agency"

    End Select

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,138
    I dno't believe CASE works with LIKE comparisons... You may have to resort to if/else if statements instead
    Code:
    If {@Expense Code} Like "5641%" Then
      formula = "Admin & Clerical"
    Else If {@Expense Code} Like "5833%" Then
      formula...
    End If
    Orrr.... You could compare the first 4 characters of the code (if that suits your requirements)
    Code:
    SELECT CASE Left({@Expense Code}, 4)
      Case "5641" ....
    George
    Home | Blog

  3. #3
    Join Date
    May 2003
    Location
    UK
    Posts
    233
    The If Then Else Statement would prove really really long. However taking the first 4 characters should be spot on.

    Many thanks

Posting Permissions

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