+ Reply to Thread
Results 1 to 4 of 4

Public Function w/ Case Statement

  1. #1
    Registered User
    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.

    Please Login or Register  to view this content.
    Thx in advance
    _________________
    Regards,
    nrage21

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,885

    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
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Registered User
    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

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,885

    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.6.0 RC 1