Results 1 to 3 of 3
  1. #1
    nrage21 is offline Novice
    Windows XP Access 2003
    Join Date
    Sep 2010
    Posts
    1

    Need Help with Simple VB Function

    Hi, I suck in VB and need help with the syntax of a simple function I've named 'get_team'.



    Code:
    Public Function get_team(t_Language As String, t_Region As String, t_ZipCode As String)
           Select Case get_team
                Case t_Language IN ("EN", "CT")
                     get_team = "A"
                Case t_Language IN ("FR", "CH") AND t_Region = "S"
                     get_team = "B"
                Case t_Language("ZH", "MD") AND t_ZipCode NOT IN (10002, 11214)
                     get_team = "C"
                Case Else
                     get_team = "D"
     
        End Select
    End Function
    t_Language, t_Region, t_ZipCode refer to columns in a MS Access table (Language, Region, ZipCode).

    get_team is the value I want returned if any of the cases criteria are met. This value will be placed in a column named Team.

    Thx in advance

    Nrage21

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    I see a couple of things right off. This line should be:

    Select Case t_Language

    I don't think IN works there, so these would be:

    Case "EN", "CT"

    Not sure you can use AND, so try

    Code:
    Case "FR", "CH"
      If t_Region = "S"  
        get_team = "B"
      Else
        get_team = "D"
      End If
    Case ...
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    since there so many different conditions, I would prefer IF...ELSEIF...ELSE...END IF, it must be much easier.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Simple Export Not So Simple
    By jgelpi16 in forum Programming
    Replies: 11
    Last Post: 09-01-2010, 07:23 AM
  2. This must be simple but.....
    By adi in forum Access
    Replies: 11
    Last Post: 07-30-2010, 06:12 AM
  3. Simple math
    By Lee in forum Programming
    Replies: 2
    Last Post: 07-27-2010, 04:53 PM
  4. Want function to get current function name
    By Davis DeBard in forum Programming
    Replies: 2
    Last Post: 08-13-2009, 05:02 AM
  5. Very simple question!
    By fiddley in forum Programming
    Replies: 2
    Last Post: 04-28-2009, 02:16 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums