[AccessD] Data type mismatch in function

Kaup, Chester Chester_Kaup at kindermorgan.com
Wed Dec 5 13:48:15 CST 2012


Thanks. Commas are the answer.

-----Original Message-----
From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of David McAfee
Sent: Wednesday, December 05, 2012 1:12 PM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] Data type mismatch in function

I just created a little database with a simple table and it works using this function:

Public Function WellStatus(Status As String) As String Dim ReturnStatus As String  Select Case Status
    Case "FL", "FM", "FH", "PL", "PM", "PH", "SL", "SM", "SH", "SP", "RL", "RM", "RH", "RP"
        ReturnStatus = "PRD"
    Case "CI", "WAGC"
        ReturnStatus = "GasI"
    Case "WD", "WI", "WC", "WCH", "WF"
        ReturnStatus = "WI"
    Case Else
        ReturnStatus = ""
 End Select
 WellStatus = ReturnStatus
End Function


Here's the test query:
SELECT StatusChange.ID, StatusChange.Status, WellStatus([Status]) AS ReturnStatus FROM StatusChange;

and the results:

Query1
ID Status ReturnStatus
1 FL PRD
2 FM PRD
3 FL PRD
4 FH PRD
5 PL PRD
6 PM PRD
7 LA
8 PH PRD
9 SL PRD
10 PA
11 CI GasI
12 WD WI
13 WI WI
14 NV



On Wed, Dec 5, 2012 at 11:03 AM, David McAfee <davidmcafee at gmail.com> wrote:
>
> Did you replace every Or in the function with a comma?
>
>
--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com




More information about the AccessD mailing list