I need to look up an item while entering a sales order and determine whether there are any FIFO tiers over 90 days old. So far I've been able to use the .movefirst and .movenext methods to accomplish this, but performance is poor. Is there a way to jump to a particular point in the data (by item code?).
oItemCost = oSession.GetObject("IM_ItemCost_bus")
Set oItemCost = oSession.AsObject(oItemCost)
oItemCost.MoveFirst()
Do until cBool(oItemCost.Eof) or Found = 1
Do While strItemNo = strItemNoCheck
strFifoDate = ""
Qty = 0
strItemNoCheck = ""
strWHSCode = ""
strTierType = ""
retVal = oItemCost.GetKey("ItemCode$", strKey)
retVal = oItemCost.GetValue("ItemCode$", strItemNoCheck)
retVal = oItemCost.GetValue("WarehouseCode$", strWHSCode)
retVal = oItemCost.GetValue("TierType$", strTierType)
retval = oItemCost.GetValue("ReceiptDate$", strFifoDate)
retval = oItemCost.GetValue("QuantityOnHand", Qty)
'set flag indicating that item FIFO tiers were found
Found = 1
strday = right(strFifoDate,2)
strmonth = mid(strFifoDate,5,2)
stryear = left(strFifoDate,4)
strFifoDate = strmonth & "/" & strday & "/" & stryear
DaysDiff = DateDiff("d",strFifoDate,Now())
if DaysDiff > 90 and Qty > 0 and trim(strTierType) = "1" then
strTierInfo = "There are " & formatnumber(Qty) & " of item # " & strItemNo & " in warehouse " & strWHSCode & " received on " & strFifoDate & " (" & formatnumber(DaysDiff) & " days old). " & vbCrLf & strTierInfo
End If
oItemCost.MoveNext()
Loop
oItemCost.MoveNext()
Loop
if trim(strTierInfo) <> "" then
oSession.AsObject(oSession.UI).MessageBox(trim(strTierInfo))
End If