I have a file with the stock in it set at zero
I have a file with all the stock as it was counted - some items can be in the counted file more than once as they may have been in different places. I have started to write my code to update but have got lost in the middle
I can collect all the records one at a time but then how do i add them this total to the total of the original
....
Public Function CountStock()
Dim CurrBC As String
Dim CurrCount As Double
Dim OldCount As Double
Dim NewCount As Double
Dim lacDB As Database
Dim lacRS As DAO.Recordset, lacRS2 As DAO.Recordset
Set lacDB = CurrentDb()
Set lacRS = lacDB.OpenRecordset("StockTake")
Set lacRS2 = lacDB.OpenRecordset("StocktakeQuantity")
Do Until lacRS.EOF
If lacRS![Updated] = "0" Then
'Do Until lacRS2.EOF
'If lacRS2![BarCode] = lacRS![MasterBC] Then
'lacRS2.Edit
'lacRS2![qtyzero] = lacRS2![qtyzero] + lacRS![ExtQty]
'lacRS2.Update
'End If
End If
lacRS.MoveNext
Loop
lacRS.Close
lacRS2.Close
lacDB.Close
Set lacRS = Nothing
Set lacRS2 = Nothing
Set lacDB = Nothing
End Function
I have a file with all the stock as it was counted - some items can be in the counted file more than once as they may have been in different places. I have started to write my code to update but have got lost in the middle
I can collect all the records one at a time but then how do i add them this total to the total of the original
....
Public Function CountStock()
Dim CurrBC As String
Dim CurrCount As Double
Dim OldCount As Double
Dim NewCount As Double
Dim lacDB As Database
Dim lacRS As DAO.Recordset, lacRS2 As DAO.Recordset
Set lacDB = CurrentDb()
Set lacRS = lacDB.OpenRecordset("StockTake")
Set lacRS2 = lacDB.OpenRecordset("StocktakeQuantity")
Do Until lacRS.EOF
If lacRS![Updated] = "0" Then
'Do Until lacRS2.EOF
'If lacRS2![BarCode] = lacRS![MasterBC] Then
'lacRS2.Edit
'lacRS2![qtyzero] = lacRS2![qtyzero] + lacRS![ExtQty]
'lacRS2.Update
'End If
End If
lacRS.MoveNext
Loop
lacRS.Close
lacRS2.Close
lacDB.Close
Set lacRS = Nothing
Set lacRS2 = Nothing
Set lacDB = Nothing
End Function