Here is my code. When it runs, count goes to 32,767. The procedure is only working with 5 records.
I tried MoveLast and MoveFirst together with no result.
strSQL = "SELECT * FROM People WHERE people.household_id=" & ziprec!household_id
Set peoplerec = CurrentDb.OpenRecordset(strSQL)
With peoplerec
While (Not peoplerec.EOF)
currentage = DateDiff("yyyy", !birthday, rightnow)
Select Case currentage
Case 0 To 4
age_under5 = age_under5 + 1
Case 5 To 17
age_5to17 = age_5to17 + 1
Case 18 To 64
age_18to64 = age_18to64 + 1
Case Else
age_over65 = age_over65 + 1
End Select
count = count + 1
.MoveNext
Wend
End With
The code should go through the five records and count the number of people in each age group. It does go through all five records, but endless times.
While (Not peoplerec.EOF)should beWhile Not .EOFinside theWithexpression.