Public Sub GetAttendance()

   Dim oClassAtts As cEAClassAttendances

   Dim oClassAtt As cEAClassAttendance

   Dim oServices As FE_Services

   Dim oUtility As IBBUtilityCode

   Dim lSessionID As Long

   Dim lStudentID As Long

   Dim bHasDups As Boolean

   Dim oAttCode As cEAAttendanceCode

   Dim sAttCode As String

   Dim oClasses As cEAClasses

   Dim oClass As cEAClass

   Dim sClassName As String

   Dim sSQL As String

   

   Set oServices = New FE_Services

   oServices.Init FE_Application.SessionContext

   Set oUtility = oServices

   With oUtility

       'Will use SessionID and StudentId as filters for the attendance

       lSessionID = .eaSessionsGetSessionID("Regular", "Upper", "2004-2005", True)

       lStudentID = .eaRecordsGetRecordIDFromName(staticentry_PersonRecordType_StudentEA, "Andrews Michael", bHasDups:=bHasDups)

       If bHasDups Or lStudentID = 0 Then

           'Need to add code to handle the ID not being passed back or more

           'then one student matching the name

       End If

   End With

   Set oUtility = Nothing

   oServices.CloseDown

   Set oServices = Nothing

   

   Set oClassAtts = New cEAClassAttendances

   oClassAtts.Init FE_Application.SessionContext

   'Filtering which attendance records to use

   oClassAtts.FilterObject.FilterProperties(EAATTENDANCEBYCLASS_FilterProp_Session) = lSessionID

   oClassAtts.FilterObject.FilterProperties(EAATTENDANCEBYCLASS_FilterProp_Student) = lStudentID

   

   'loop through all the attendance records for my filters

   For Each oClassAtt In oClassAtts

       With oClassAtt

           'Getting the Attendence code for this attendance entry

           Set oAttCode = New cEAAttendanceCode

           oAttCode.Init FE_Application.SessionContext

           oAttCode.Load .Fields(EAATTENDANCEBYCLASS_fld_EA7ATTENDANCECODESID)

           sAttCode = oAttCode.Fields(EAATTENDANCECODES_fld_DESCRIPTION)

           oAttCode.CloseDown

           Set oAttCode = Nothing

           

           'Getting the class and session associated with this attendance entry

           sSQL = "EA7CLASSES.EA7CLASSESID in " & _

               "(SELECT EA7CLASSTERMS.EA7CLASSESID FROM EA7CLASSTERMMEETINGS " & _

               "INNER JOIN EA7CLASSTERMS ON EA7CLASSTERMMEETINGS.EA7CLASSTERMSID " & _

               "= EA7CLASSTERMS.EA7CLASSTERMSID WHERE " & _

               "(((EA7CLASSTERMMEETINGS.EA7CLASSTERMMEETINGSID)= " & _

               .Fields(EAATTENDANCEBYCLASS_fld_EA7CLASSTERMMEETINGSID) & ")));"

           Set oClasses = New cEAClasses

           oClasses.Init FE_Application.SessionContext

           oClasses.FilterObject.CustomFilterProperty(CUSTOMFILTERTYPE_CUSTOMWHERE) = sSQL

           If oClasses.Count = 1 Then

               'should never get anything but one record in oClasses with this where clause

               Set oClass = oClasses.Item(1)

               sClassName = oClass.Fields(EACLASSES_fld_COURSE) & " - " & oClass.Fields(EACLASSES_fld_CLASSSECTION)

               oClass.CloseDown

               Set oClass = Nothing

           End If

           oClasses.CloseDown

           Set oClasses = Nothing

           

           'Showing all the fields for the attendance entry in the immediate debug window

           Debug.Print .Fields(EAATTENDANCEBYCLASS_fld_ATTENDANCEDATE) & " - " & _

               .Fields(EAATTENDANCEBYCLASS_fld_CYCLEDAY) & " - " & .Fields(EAATTENDANCEBYCLASS_fld_STARTTIME) & _

               " - " & sClassName & " - " & sAttCode

           .CloseDown

       End With

   Next oClassAtt

   Set oClassAtt = Nothing

   oClassAtts.CloseDown

   Set oClassAtts = Nothing

   

End Sub

Disclaimer: We provide programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes you are familiar with Microsoft Visual Basic and the tools used to create and debug procedures. Our Customer Support can help explain the functionality of a particular procedure, but we will not modify, or assist you with modifying, these examples to provide additional functionality. If you are interested in learning more about the VBA and API modules, contact your account manager.