Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Public Function basRunningSumByDate()
'tblPatDose
'ID Date Quantity
'1 1/1/99 10
'1 2/15/99 12
'1 3/18/99 5
'2 1/5/99 7
'2 5/1/99 8
'2 5/21/99 10
Dim dbs As Database
Dim rst As Recordset
Dim MyPatient As Long 'Patient ID
Dim MySum As Long 'Patient Sum
Dim ExceedFlg As Boolean
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("tblPatDose", dbOpenDynaset)
While Not (rst.EOF)
ExceedFlg = False
MyPatient = rst!Id 'Get a patient ID
MySum = 0
Do While rst!Id = MyPatient
With rst
MySum = MySum + !Quantity
.Edit
If (MySum > 20 And Not ExceedFlg) Then
!Over20 = True
ExceedFlg = True
Else
!Over20 = False
End If
.Update
End With
rst.MoveNext
If (rst.EOF) Then
Exit Function
End If
Loop
Do While rst!Id = MyPatient
rst.MoveNext
If rst.EOF Then
Exit Function
End If
Loop
Wend
End Function
[b]
Id DoseDate Quantity Over20[/b]
1 1/1/99 10 No
1 2/15/99 12 Yes
1 3/18/99 5 No
2 1/5/99 7 No
2 5/1/99 8 No
2 5/21/99 10 Yes