Public Function Debit(iStudentID As Integer) As Boolean
On Error GoTo Debit_Error_Handler
' this method will add the book price amount
' to the student's account balance.
Dim rsStudent As ADODB.Recordset
Dim dCurrentBalance As Double
Dim dNewBalance As Double
' create the recordset object
Set rsStudent = New ADODB.Recordset
' get the student record for the studentID passed in
rsStudent.Open "Select AccountBalance from Students where StudentID = " & Str(iStudentID), cnStateUBookstore, adOpenKeyset, adLockOptimistic
' get the current balance
dCurrentBalance = rsStudent!AccountBalance
' calculate the new balance
dNewBalance = dCurrentBalance + mvarPrice
' update the account balance for this student
rsStudent!AccountBalance = dNewBalance
rsStudent.Update
' close and release the recordset object
rsStudent.Close
Set rsStudent = Nothing
' return success
Debit = True
Exit Function
Debit_Error_Handler:
RaiseEvent Warning(Err.Description)
Debit = False
End Function