'Recordset Not Updating Table with Changed and/or Correct Values

The codes purpose is to 'build' the correct name style for each record in a CDSal and FormatName field. I have a group of tables (all linked) with individuals Full Name(NewName), Salutation, First, Middle and Last Name, as well as Client defaults for what to do with those names (!NewName, !First, !AA, etc.).

The Recordset is pulled from a query in the database that brings some necessary fields together from 2 different tables. From Access I can open the query, make any changes needed to any of the fields, save the record and see the changes reflected in the underlying tables. When I run the following code, the Debug.Print's produce the expected outcomes but nothing is permanently saved to the tables. The code never errors (which might be part of the problem) and for Case "!AA" both CDSal and FormatName fields are filled with !NewName when Debug.Print again shows the expected outcome. Case "!AA" is the only instance where anything is actually changed on the tables.

I have attempted everything that I could find on the Internet to troubleshoot this error as well as multiple different configurations to get something to "stick". Hopefully it is a simple answer, let me know what you all think.

Private Sub Form_Load()
On Error GoTo Form_Load_Err

'_ SetUp Variables _'
Dim strQry As String, strSQL As String, strName As String
Dim rstName As DAO.Recordset

'_ Declare Variables _'
strQry = "MyQueryName"
Set rstName = CurrentDb.OpenRecordset(strQry, dbOpenDynaset)

'_ Begin Code _'
    With rstName
    If Not (.EOF And .BOF) Then .MoveFirst
    Do Until .EOF = True
'Update CDSal with correct Naming Information
Debug.Print !NewName
    .Edit
    Select Case !CDSal_Client
    Case "NewName"     'Clients that use NewName for blah
        !CDSal = !NewName
    Case "First"       'Clients that use First for blah
        !CDSal = !First
    Case "AA"          'ClientName: CDSal = First, FormatName = NewName(w/o Sal)
        !CDSal = !First
        If !Sal <> "" Then
            !FormatName = !First & " " & !Middle & " " & !Last
        Else
            !FormatName = !NewName
        End If
    Case "BB"          'ClientName: Client uses specific breakdown for names
        If !Sal <> "" And !Last <> "" Then
            !CDSal = !Sal & " " & !Last
            !FormatName = !Sal & " " & !Last
        ElseIf !First <> "" And !Last <> "" Then
            !CDSal = !First & " " & !Last
            !FormatName = !First & " " & !Last
        ElseIf !First <> "" Then
            !CDSal = !First
            !FormatName = !First
        Else
            !CDSal = "Valued Member"
            !FormatName = "Valued Member"
        End If
    Case "CC"          'ClientName: CDSal = NewName(trim " & " if needed) = NewName + AddlName(done on import)
        If Right(!NewName, 3) = " & " Then
            Replace !NewName, " & ", ""
            !CDSal = !NewName
        Else
            !CDSal = !NewName
        End If
    End Select
    .Update
Debug.Print !CDSal
Debug.Print !FormatName
    .MoveNext
    Loop
'Removes additional spaces left over from concatenating fields
strSQL = "UPDATE [" & strQry & "] SET [FormatName] = REPLACE(REPLACE(REPLACE([FormatName],' ','<>'),'><',''),'<>',' '), " & _
            "[CDSal] = REPLACE(REPLACE(REPLACE([FormatName],' ','<>'),'><',''),'<>',' ');"
    CurrentDb.Execute strSQL
    End With
'_ Error Handling & CleanUp
Form_Load_ClnUp:
    rstName.Close
    Set rstName = Nothing
    Exit Sub
Form_Load_Err:
    MsgBox Err.SOURCE & " : " & Err.Number & vbCr & _
        "Error Description : " & Err.Description
    GoTo Form_Load_ClnUp
End Sub

MyQueryName SQL

SELECT T_Individual.ID_IndivRecords, T_Individual.NewName, T_Individual.NewName2, T_Individual.CDSal, T_Individual.FormatName, T_Individual.Status_, T_Individual.Sal, T_Individual.First, T_Individual.Middle, T_Individual.Last, T_Clients.ID_Client, T_Clients.CDSal_Client, T_Individual.Date
FROM T_Individual INNER JOIN (T_Clients INNER JOIN (T_Jobs INNER JOIN T_IndivJobs ON T_Jobs.ID_Jobs = T_Individual.Jobs) ON T_Clients.ID_Client = T_Jobs.Client) ON T_Individual.ID_IndivRecords = T_IndivJobs.ID_DonorRecords
WHERE (((T_Individual.Date)=Date()));


Solution 1:[1]

strSQL = "UPDATE [" & strQry & "] SET [FormatName] = REPLACE(REPLACE(REPLACE([FormatName],' ','<>'),'><',''),'<>',' '), " & _
            "[CDSal] = REPLACE(REPLACE(REPLACE([FormatName],' ','<>'),'><',''),'<>',' ');"

Another instance of a simple error and or mistype can drastically affect everything you are trying to achieve. This SQL was ran after the code was processed to remove any double spaces that might have been in the original data or created from concatenation. Notice that the CDSal field will be replaced with the FormatName field in the last line instead of being replaced with itself. Since most records do not use the FormatName field their CDSal field was getting replaced with NULL . . . I have corrected this issue and everything runs very smoothly and correctly now. Thanks for everyone who tried to help on this! Any additional information on Formatting or Optimization is always appreciated.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 James Crafton