new access need helps with run sum query

  • Thread starter Thread starter anonymous
  • Start date Start date
A

anonymous

How do i change the units stock and cat id in this sample
to PRDCD-Q and SALES Q?
Option Compare Database
Option Explicit

Function fncRunSum(lngCatID As Long, lngUnits As Long) As
Long
'Variables that retain their values.
Static lngID As Long
Static lngAmt As Long

If lngID <> lngCatID Then
'If the current ID does not match the last ID,
then (re)initialize.
lngID = lngCatID
lngAmt = lngUnits
Else
'If the current ID matches the last, keep a
running sum for the ID.
lngAmt = lngAmt + lngUnits
End If

'Pass the running sum back to the query.
fncRunSum = lngAmt
End Function
 
Back
Top