the following codes 'seems' to loop through all of the records in the table, yet the debug.print shows that the values being returned are always those of the first record in the table.
this code is in the Load event of the form; the results of the loop are assigned to values in the report header section.
fields FxtTag and Qty are valid fields (with entries)
Code:
Dim intCnt_Comply As Integer
Dim intCnt_NotComply As Integer
intCnt_Comply = 0
intCnt_NotComply = 0
Dim rs As DAO.Recordset
Set rs = CurrentDb.OpenRecordset("SELECT * FROM tbeFxtTagDetails")
'Check to see if the recordset actually contains rows
If Not (rs.EOF And rs.BOF) Then
rs.MoveFirst
Do Until rs.EOF = True 'loop through all the records in the table
Debug.Print FxtTag & " | " & CStr(Qty)
If [Efficacy] >= intNYC_MinLampEff Then
intCnt_Comply = intCnt_Comply + Nz(Qty, 0)
Else
intCnt_NotComply = intCnt_NotComply + Nz(Qty, 0)
End If
rs.MoveNext
Loop
'Else
' MsgBox "There are no records in the recordset."
End If
MsgBox "Finished looping through records."
rs.Close
Set rs = Nothing
i'm confused (seems like i've ran variations of this code a billion-zillion times; yet tonight (!?!)
with appreciation in advance,
m.