My form is linked to a table and the code seems to work. I can see a messagebox that shows the records are being changed to the next record. That is, the names change in the messagebox. However, the created data changes for the field on the first record. The employee's name stays the same on the form's textbox during execution. The program is suppose to change each Distance field in the table. I tried making the second update for a different value (test13), but it just overwrote the first record. That is, changed test12 to test13. Code is below. Thanks for any help.
Code:
Private Sub Command16_Click()
Dim Rst As DAO.Recordset
Dim Fld As Forms
Set Rst = CurrentDb.OpenRecordset("replacementzip")
Dim StrInput As String
StrInput = "test12"
If Rst.RecordCount <> 0 Then
Rst.MoveFirst
Do While Not Rst.EOF
txtDistance = StrInput
Distance = Me.txtDistance 'txtDistance does update the first record
Me.Requery
MsgBox "name and hrid " & Rst!FirstNM & ", " & Rst!HRID & ", " & Me.Distance
Rst.MoveNext 'MoveNext seems to work, that is, I can see the changes in name in messagebox, but nothing changes in the name field on the form, I don't see any subsequent employee change in the form's textboxes.
StrInput = "test13" 'this overwrote the first record with test13 rather than going to the second record and updating.
Loop
End If
Rst.Close
Set Rst = Nothing
MsgBox "Finished"
End Sub