stevebanks
Programmer
- Mar 30, 2004
- 93
Hi,
I have a bit of code which is forecasting through a recordset and updating records with stock data from the previous weeks sales/returns/cancellations forecast...
It's working, but not quite how i need it to! Hence the question!
The code is:
Sorry if the code is a bit messy, i'm relatively new to this.
My trouble is, the "fcast_details" table contains data for all products. I need the stock levels to update for each product separately. I have been trying to use:
But it's not working and causing an error. Trouble at the moment is I'm getting stock data between products mixed up..
Please can someone help!!!
Thanks ever so much
Steve
I have a bit of code which is forecasting through a recordset and updating records with stock data from the previous weeks sales/returns/cancellations forecast...
It's working, but not quite how i need it to! Hence the question!
The code is:
Code:
Function updfcaststocklevel()
Dim rs As DAO.Recordset
Dim db As Database
Set db = CurrentDb()
Set rs = db.OpenRecordset("fcast_details")
rs.MoveFirst
Do Until rs.EOF
i = i + 1
If i = 1 Then
stklevel = rs("fcaststocklevel")
Else
stklevel = stklevel - rs("fcastdemand") + rs("fcastreturns") - rs("fcastcancellations")
End If
rs.Edit
rs("fcaststocklevel") = stklevel
rs.Update
rs.MoveNext
Loop
MsgBox ("Done!")
End Function
Sorry if the code is a bit messy, i'm relatively new to this.
My trouble is, the "fcast_details" table contains data for all products. I need the stock levels to update for each product separately. I have been trying to use:
Code:
Dim itemcode As Variant
itemcode= rs("itemcode")
For each itemcode In rs
blah blah blah
Next
Please can someone help!!!
Thanks ever so much
Steve