Well, I need to retrieve a list of dates where the criteria is >= a field on a form. Then I retrieve the Inventory Details for each date, and for each detail I need to update the Cost field to either
1) the cost the last time the item was delivered OR
2) if the item was not delivered since the last inventory, the cost at the last inventory. ( i use this somewhere else, and it looks like this :
Dim x As Double
Dim y As Double
Dim z As Double
x = Nz(DLookup("Conversion", "tblVendor_Item", "InventoryItemNumber = " & "Forms!frmInventoryEdit!InventoryItemNumber"), 1)
y = Nz(DLookup("Con", "qryInventory", "InventoryItemNumber = " & "Forms!frmInventoryEdit!InventoryItemNumber"), 1)
z = Nz(DLookup("UnitPrice", "qryMostRecentCost2", "InventoryItemNumber = " & "Forms!frmInventoryEdit!InventoryItemNumber"), 0)
If IsNull(z) Or z = 0 Then
Me.LastCost = Nz(DLookup("LastCost", "qryPrevLastCost3", "InventoryItemNumber = " & "Forms!frmInventoryEdit!InventoryItemNumber"), 0)
Else
Me.LastCost = (z / x) * y
End If
Then move to the next date in the list, in ascending order.