Function crhr(ID As String) As Integer

 

    Dim rst As ADODB.Recordset

    Set rst = New ADODB.Recordset

    rst.ActiveConnection = CurrentProject.Connection

    rst.CursorType = adOpenStatic

    rst.Open "Select Take.[Student#], Sum(COURSE.CrHour) AS SumOfCrHour FROM COURSE INNER JOIN Take ON COURSE.[Course#] = Take.[Course#] GROUP BY Take.[Student#]"

    rst.Find "Student# = '" & ID & "'"

    crhr = rst("SumOfCrHour")

    Debug.Print crhr

    rst.Close

    Set rst = Nothing

 

End Function

 

Private Sub Command31_Click()

Dim Status As Boolean

Dim Resident As Boolean

Dim NumCrHr As Integer

Dim tuition As Long

 

If [UnderGrad?] = True Then

    Status = True

Else

    Status = False

End If

Debug.Print [Student#]

Debug.Print "Undergrad status is " & Status

 

If [State] = "KY" Then

    Resident = True

Else

    Resident = False

End If

Debug.Print "KY resident is " & Resident

 

NumCrHr = crhr([Student#])

 

If (Status = True) And (Resident = True) And (NumCrHr >= 12) Then

    tuition = 1987.25

    Debug.Print tuition

End If

 

If (Status = True) And (Resident = True) And (NumCrHr < 12) Then

    tuition = 158.4 * NumCrHr

    Debug.Print tuition

End If

 

 

End Sub