Here is a portion of some code I posted in another message:
Notice that "rs" is a handle to a record set which is opened with OpenRecordSet.
That handle is how you can reference anything having to do with that recordset, whether it is a field found in the records of the recordset, or the end-of-file condition or anything else. In this sample, [Item], [Warehouse] and [OnHand] are all fields in my records of the recordset.
This code again is only a portion of a program, it's not supposed to look complete.
Jim
- Set db = CurrentDb
-
-
Set rs = db.OpenRecordset("ItemWarehouse")
-
Onhandqty = 0
-
On Error GoTo Loopend
-
rs.MoveFirst
-
-
strFind = "Item='" & CStr(ItemNbr) & "'"
-
rs.FindFirst (strFind) ' first occurrence of this item in itemwh file
-
-
LoopItems:
-
While (Not (rs.EOF))
-
If rs.NoMatch Then GoTo Loopend
-
If rs![Item] <> ItemNbr Then GoTo NextItem
-
' If rs![Warehouse] <> "9301" And rs![Warehouse] <> "3405" Then GoTo NextItem
-
If rs![Warehouse] = "PCR" Then GoTo NextItem
-
Counter = Counter + 1
-
Onhandqty = Onhandqty + rs![OnHand]
-
If Counter > 1 Then GoTo Loopend 'don't bother looking after we found both warehouses
-
NextItem:
-
rs.FindNext (strFind)
-
-