I am entering data into a database concerning complaints, and I need to use some sort of "red flag" or "early warning signal", to identify if this person has submitted complaints before.. This is the code, I have so far. It only works by identifying the first record in the table. How do i get it to loop through the table.
Private Sub txtVictimName_AfterUpdate()
Dim rst As Recordset, dbs As Database, iRecCount As Long, iCount As Long, vTemp As Variant
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("select victimname from tblFPU order by victimname asc"
If Not rst.EOF Then
rst.MoveLast
iCount = rst.RecordCount
End If
Do Until rst.EOF
If Me.txtVictimName = rst.Fields("VictimName"
.Value Then
vTemp = "Victim's Name: " & rst.Fields("VictimName"
.Value & vbCrLf & "Number of Complaints: " & iCount
MsgBox vTemp
End If
rst.MoveNext
Loop
rst.Close
End Sub
Private Sub txtVictimName_AfterUpdate()
Dim rst As Recordset, dbs As Database, iRecCount As Long, iCount As Long, vTemp As Variant
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("select victimname from tblFPU order by victimname asc"
If Not rst.EOF Then
rst.MoveLast
iCount = rst.RecordCount
End If
Do Until rst.EOF
If Me.txtVictimName = rst.Fields("VictimName"
vTemp = "Victim's Name: " & rst.Fields("VictimName"
MsgBox vTemp
End If
rst.MoveNext
Loop
rst.Close
End Sub