Question : Defining variables to display words based on coded values

I have a db field [Tdir] that's encoded with "N", "S", "E", or "w" to represent north, south, east, and west. I'm trying to have it write out the full word based on the code in a form. How do I modify the following code to do this?

 
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
Private Function 
formatstr
    Dim Tdir, T
    Tdir = getval(rst, "Tdir")
    T = getval(rst, "T")

    formatstr = Tract
    If T > "" Then formatstr = formatstr + ", Township " + T + " " + Tdir
               
        End Select
    End If
    
End Function

Answer : Defining variables to display words based on coded values

Seems simple enough...

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
Private Function formattract(rst As dao.Recordset) As String
    Dim Tract, Survey, BlockNum, SurveyName, Acreage, formatstr
    Dim S, R, Rdir, T, Tdir, County, State, TractOnly
    Tract = getval(rst, "Tract")
    Survey = getval(rst, "Survey")
    BlockNum = getval(rst, "BlockNum")
    SurveyName = getval(rst, "SurveyName")
    Acreage = getval(rst, "Acreage")
    S = getval(rst, "S")
    R = getval(rst, "R")
    Rdir = getval(rst, "Rdir")
    T = getval(rst, "T")
    Select Case getval(rst, "Tdir")
        Case "N": Tdir = "North"
        Case "S": Tdir = "South"
        Case "E": Tdir = "East"
        Case "W": Tdir = "West"
        Case Else: Tdir = "<unknown!>"
    End Select
    County = getval(rst, "County")
    State = getval(rst, "State")
    TractOnly = getval(rst, "TractOnly")
    
    formatstr = Tract
    If TractOnly = False Then
        Select Case UCase(State)
            Case "TX", "TEXAS"
                If Survey > "" Then formatstr = formatstr + " of Section " + Survey
                If BlockNum > "" Then formatstr = formatstr + ", Block " + BlockNum
                If SurveyName > "" Then formatstr = formatstr + ", " + SurveyName
                If County > "" Then formatstr = formatstr + ", in " + County + " County, Texas"
                If Acreage > "" Then formatstr = formatstr + " containing approximately " + CStr(Acreage) + " acres, more or less."
            Case "OK", "OKLAHOMA"
                If S > "" Then formatstr = formatstr + " of Section " + S
                If T > "" Then formatstr = formatstr + ", Township " + T + " " + Tdir
                If R > "" Then formatstr = formatstr + ", Range " + R + ", " + Rdir
                If County > "" Then formatstr = formatstr + " of the Cimarron Meridian, " + County + " County, Oklahoma"
                If Acreage > "" Then formatstr = formatstr + " containing approximately " + CStr(Acreage) + " acres, more or less."
        End Select
    End If
    formattract = Replace(formatstr, ",,", ",") ' get rid of double commas
    
End Function
Random Solutions  
 
programming4us programming4us