Here is my code:
What I am needing this to do is search through my table to match the value of the Field "ID" to the value of (ID), which is a txtBox on a form bound to another table. If it matches these two values then I need it to do the calculations in the If statement. It works for the first record, but will not work for any of the other records. Both ID fields are autonumber fields.
Code:
Dim db As DAO.Database
Dim rs1 As DAO.Recordset
Set db = CurrentDb()
Set rs1 = db.OpenRecordset("CartUse")
rs1.MoveFirst
Do Until rs1.EOF
If rs1.Fields(ID) = Val(ID) Then
NumOrdTotal = Val(rs1.Fields(varLongMonth)) + Val(varNumOrd)
txttest2 = Val(NumOrdTotal)
rs1.Edit
rs1.Fields(varLongMonth) = Val(NumOrdTotal)
rs1.Update
End If
rs1.MoveNext
Loop
rs1.Close
Set rs1 = Nothing
Set db = Nothing
Comment