Sub SW_KeepLastValue(action) 'This function uses the Settings object to save field values 'entered into the last defect posted by each user. ' ' The action passed to the user-defined function SW_KeepLastValue ' is GET or SET. ' ' If the action is SET, the function stores the values of the ' fields BG_DETECTION_VERSION, BG_USER_01, and BG_USER_03 in ' the common settings table for the current user. ' ' If the action is GET, the function reads the values from the ' settings object and assigns the values to the appropriate fields. ' Dim tdc, vals, flds Dim uset, pairs, pair Dim bld On Error Resume Next bld = "" Set tdc = TDConnection Set uset = tdc.UserSettings If action = "SET" Then flds = Array("BG_DETECTION_VERSION", _ "BG_USER_01", "BG_USER_03") vals = "" For i = 0 To UBound(flds) If vals <> "" Then vals = vals & ";" vals = vals & flds(i) & _ "=" & Bug_Fields(flds(i).value) Next ' Open category KeepLValueSetting. uset.Open ("KeepLValueSetting") ' Set KeepValueFields in category KeepLValueSetting. uset.value("KeepValueFields") = vals uset.Close End If If action = "GET" Then uset.Open ("KeepLValueSetting") vals = uset.value("KeepValueFields") If vals <> "" Then pairs = Split(vals, ";") For i = 0 To UBound(pairs) pair = Split(pairs(i), "=") If UBound(pair) = 1 Then Select Case pair(0) Case "BG_USER_03" bld = pair(1) Case Else If Bug_Fields(pair(0).value) = "" Then Bug_Fields(pair(0).value) = pair(1) End If End Select If Bug_Fields("BG_DETECTION_VERSION").value <> "" _ And bld <> "" Then SW_SetLists_VersionsBuilds _ "BG_DETECTION_VERSION", "BG_USER_03" Bug_Fields("BG_USER_03").value = bld If err.Number <> 0 Then err.Clear End If End If Next End If End If uset.Close If err.Number <> 0 Then SW_DisplayError err.Number, err.Description, _ "Keep Last Value (" & action & ")" End If End Sub