Private Sub cmdUpdate_Click()
On Error GoTo cmdUpdate_Error
Dim curDatabase As Object
Dim rstEmployees As Object
Dim fldEmployee As Object
Set curDatabase = CurrentDb
Set rstEmployees = curDatabase.OpenRecordset("Employees")
With rstEmployees
Do Until .EOF
For Each fldEmployee In .Fields
If fldEmployee.Name = "EmployeeID" Then
If fldEmployee.Value = CInt(txtEmployeeID) Then
' The record to be edited has been located
.Edit
.Fields("DateHired").Value = txtDateHired
.Fields("FirstName").Value = txtFirstName
.Fields("LastName").Value = txtLastName
.Fields("HourlySalary").Value = txtHourlySalary
.Update
Exit For
End If
End If
Next
.MoveNext
Loop
End With
Exit Sub
cmdUpdate_Error:
MsgBox "There was a problem when editing the record."
End Sub