Results 1 to 5 of 5
  1. #1
    New Lounger
    Join Date
    Sep 2006
    Location
    Johannesburg, Gauteng, South Africa
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    If Then with multiple strings??

    How do I set up an If Then statement for the following situation:

    If the county equals one of the following: Bronx, New York, Queens or Brunswick Then set me.territory as "1", If the county equals one of ... then set me.territory as "2".

    I'm just not sure how to set it up for the If looking through multiple strings. Thanks for your help.

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

    Re: If Then with multiple strings??

    I'd suggest you use a Select Case instead of an If...End If. Using Select Case, you'd do it like this:

    <pre>Select Case Me!County
    Case "Bronx","New York","Queens","Brunswick"
    Me!Territory = 1
    Case "Brooklyn"
    Me!Territory = 2
    Case Else
    Me!Territory = 0
    End Select
    </pre>


    Obviously, I didn't know what your conditions all were, but this will give you the idea.
    Charlotte

  3. #3
    New Lounger
    Join Date
    Sep 2006
    Location
    Johannesburg, Gauteng, South Africa
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: If Then with multiple strings??

    Charlotte,
    Thanks! Appreciate it. Never was strong with my Case statements - so I never think of them!

  4. #4
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Brisbane, Queensland, Australia
    Posts
    352
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: If Then with multiple strings??

    Generally I would not hardwire this in code. I would set up a table with County and Territory fields and use a relationship to link this to your address data.

    This allows you to make changes easily when needed and is simpler for people to understand.
    David Grugeon
    Brisbane Australia

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

    Re: If Then with multiple strings??

    In general, I agree, assuming that address data was, indeed, involved. I had an app once that needed county in order to determine what text to use in a legal document. The catch was that the county wasn't necessarily the county of the person's residence, it was the county in which the property parcel was located.

    Ah well, we can only answer the questions that get asked, and give what advice we can.[img]/w3timages/icons/crazy.gif[/img]
    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
  •