This is taken from my own code, so there maybe a bit too much info, so apologies for that. It simply gets a record, gets a field (Fields(1)), then changes that data, then updates the field. The code then moves to the next record
Let me know if it helps
Grant
Dim rstSource As Recordset
Dim SQLStatement As String
Dim inputText As String
Dim outputText As String
Dim currentID As Integer
'select statement to get recordset to change
'must have two fields, a unique ID and the field to change
SQLStatement = "SELECT ProductID, ProductName FROM Products"
Set dbsCurrent = CurrentDb
Set rstSource = dbsCurrent.OpenRecordset(SQLStatement, dbOpenSnapshot)
'go through each record
With rstSource
If .RecordCount Then
.MoveFirst
Do Until .EOF
currentID = .Fields(0).Value
inputText = .Fields(1).Value
Debug.Print inputText
'new text for selected record field
outputText = "newText"
'make nice sql
outputText = Replace(outputText, "'", "''"
'update record based on unique ID
SQLUpdateStatement = "UPDATE Products SET ProductName = '" & outputText & "' WHERE ProductID=" & currentID
dbsCurrent.Execute SQLUpdateStatement
.MoveNext
Loop
End If
End With
rstSource.Close
Set rstSource = Nothing
Set dbsCurrent = Nothing
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.