Hey guys,
I am pretty new writing functions. I have a query built on a table. 2 of the fields of this table are [MNR_CD] and [VE_CD], both are text (minor code and vendor code are what these fields are fore). I want to build a function that uses both of those controls, but I don't know how to do it. Read on for more details.
We are rebuilding our entire minor code system, think of it as a dewey decimal system, of sorts. It is currently 4 characters long, and we are switching to a 6 number system. I am writing a function for each digit of the new system, then concatenating them together. The 4th digit of the new system is used for manufacturer. The english version of this function is "If the vendor code is ASHL or TMPR then the output should be 1 or 5 (respectively). If the vendor code is SEAL, look at the minor code. if the minor code is 8503, the output should be 3 and if the minor code is 8504, the output should be 4."
This is a very simplified version of what I am trying to do. There will be 8 possibilities. But if you can show me how to do that in a function. The function currently is
Code:
Public Function Fourth(OldMinor As String) As Integer
Select Case OldMinor
Case "8900"
Fourth = 5
Case "8504"
Fourth = 4
Case "8503"
Fourth = 3
Case "8501"
Fourth = 2
Case "8502"
Fourth = 3
Case Else
Fourth = 9
End Select
In the query I have "4thDigit: Fourth([MNR_CD])"
I just don't know how to get the function to also reference another field.