+ Reply to Thread
Results 1 to 4 of 4

Thread: Public Function w/ Case Statement

  1. #1
    Forum Contributor
    Join Date
    01-12-2004
    Location
    NY
    Posts
    92

    Question Public Function w/ Case Statement

    I have a table with a field called 'OLanguage'. This is a text field and stores a 2 character language (i.e. WO). I would like to use the OLanguage field to populate a field in a query called 'OTeam'.

    To accomplish this task I would like to use a VBA public function and insert several case statements. I have called the function in the query as 'OTeam: get_team([Team])

    As far as the VBA coding... this is what I have so far, but it does not work.

    Public Function get_team(OLanguage As String)
      
           Select Case OLanguage Is Not Null
          
            Case "WO"
                get_team = "A"
                
            Case Else
                get_team = "Other Team"
                            
        End Select
    End Function
    Thx in advance
    _________________
    Regards,
    nrage21

  2. #2
    Valued Forum Contributor alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Lake County, Illinois
    MS-Off Ver
    MS Office 2010, 2007 and 2002
    Posts
    1,155

    Re: Public Function w/ Case Statement

    What is not happening or what is happening. Tough to diagnose without details. As it is, it is an excercise in 'fishing'. Perhaps some more details. Describe your query in more detail, even supply your SQL statement so that we can see the whole picture. Are there only two cases or do you have many? If only two, an IIF statement would work, but I suspect you have many.
    Is this a one time event or will it be ongoing? If a one time event, then perhaps an update query?

    Alan

  3. #3
    Forum Contributor
    Join Date
    01-12-2004
    Location
    NY
    Posts
    92

    Re: Public Function w/ Case Statement

    Thx for replying Alan

    I've attached a sample mdb file for reference. I use Access 2002 in my organization.
    (don't ask me why we haven't upgraded)

    Query and SQL syntax is included of course. In regards to the case statements... I will be using many (the VBA code is in Module1).

    The query will be run every month.
    Attached Files Attached Files
    _________________
    Regards,
    nrage21

  4. #4
    Valued Forum Contributor alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Lake County, Illinois
    MS-Off Ver
    MS Office 2010, 2007 and 2002
    Posts
    1,155

    Re: Public Function w/ Case Statement

    Look at this thread. It appears to be what you are trying to do.

    http://www.access-programmers.co.uk/...d.php?t=183887

    Alan

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.2.0