From your examples, I think the query that Dal provided should be changed to:
Code:
UPDATE counties
SET counties.Court = Replace(counties.Court,"County", "Superior County");
So you would
- create a copy of the table "Counties"
- run the query
- append the changed records from the "copy of counties" to the original "counties' table.
Short and sweet....
I tend to use VBA; here is what I came up with. Like Dal said, try this on a copy of the database.
Put this code in a standard module and press the F5 key.
Code:
Private Sub AddName()
Const CN As String = "Superior "
Dim db As DAO.Database
Dim srs As DAO.Recordset
Dim drs As DAO.Recordset
Dim sSQL As String
Dim tmp As String
Dim x As Integer
Dim k As Integer
Dim j As Integer
Dim RC As Long
Dim varReturn
Set db = CurrentDb
'open target recordset
sSQL = "SELECT Status, dD, Court FROM counties"
Set drs = db.OpenRecordset(sSQL, , dbAppendOnly)
'open source recordset
sSQL = "SELECT Status, dD, Court FROM counties ORDER BY Court"
Set srs = db.OpenRecordset(sSQL, , dbReadOnly)
srs.MoveLast
RC = srs.RecordCount
srs.MoveFirst
k = 0
j = 0
Do
k = k + 1
varReturn = SysCmd(acSysCmdSetStatus, "Record " & k & " of " & RC & " / " & j & " records appended ")
x = 0
tmp = srs!court
x = InStr(1, tmp, CN)
If x = 0 Then
tmp = Replace(tmp, "County", "Superior County")
sSQL = "INSERT INTO counties ( Status, dD, Court )"
sSQL = sSQL & " VALUES ('" & srs!Status & "', '" & srs!dD & "', '" & tmp & "');"
'Debug.Print sSQL
db.Execute sSQL, dbFailOnError
j = j + 1
varReturn = SysCmd(acSysCmdSetStatus, "Record " & k & " of " & RC & " / " & j & " records appended ")
End If
srs.MoveNext
Loop Until srs.EOF
MsgBox "done"
varReturn = SysCmd(acSysCmdClearStatus)
End Sub