Hi all,
I have the code:
at the highlighted line, it shows error saying item not found in this collection (The problem is on the subRS(Qty)). I am certain that in the table called TblUnitSub that is within the recordset contains field named Qty. The table is not empty.
anyone can point where I make mistake? THanks
I have the code:
Code:
Dim dbs As Database
Dim subRS As DAO.Recordset
Dim partRS As DAO.Recordset
Dim selectSub As String
Dim selectPart As String
Dim updSubStock As String
Dim updPartStock As String
Set dbs = CurrentDb
UnitID = Me.UnitIDBox.Value
orderQty = Me.QtyBox.Value
selectSub = "SELECT * FROM TblUnitSub WHERE UnitID=" & UnitID
Set subRS = dbs.OpenRecordset(selectSub)
subRS.MoveFirst
Do While subRS.EOF = False
'subStock = DLookup("Stock", "SubUnit", "SubUnitID=" & DLookup("SubID", "TblUnitSub", "UnitSubID=" & subRS(UnitSubID)))
[highlight #FCE94F]subNeeded = subRS(Qty) * orderQty[/highlight]
MsgBox (DLookup("SubID", "TblUnitSub", "UnitSubID=" & subRS(UnitSubID)))
If subStock > subNeeded Then
subStock = subStock - subNeeded
updSubStock = "UPDATE SubUnit SET Stock=" & subStock & " WHERE UnitID=" & UnitID
MsgBox ("Stock is deducted, subStock now is " & subStock)
at the highlighted line, it shows error saying item not found in this collection (The problem is on the subRS(Qty)). I am certain that in the table called TblUnitSub that is within the recordset contains field named Qty. The table is not empty.
anyone can point where I make mistake? THanks