VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
END
Attribute VB_Name = "History"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
Option Explicit

Function ListHistoryForId(ByVal strFileDSN As String, ByVal lngAccountID As Long)
    
    Dim objContext As ObjectContext
    Set objContext = GetObjectContext
    
    On Error GoTo ErrorHandler
    
    Dim strSQL As String
    Dim rst As New ADODB.Recordset
             
    strSQL = "SELECT t.FlightDate, fs.Origin, fs.Destination, t.Miles, t.Comment " & _
             "FROM Transactions t " & _
             "JOIN FlightSchedule fs " & _
               "ON Convert(int, fs.FlightNo) = t.FlightNo " & _
             "WHERE t.AccountID = " & lngAccountID & _
             " ORDER BY t.FlightDate"
    
    rst.CursorLocation = adUseServer
    rst.Open strSQL, "FILEDSN=" & strFileDSN, adOpenStatic, adLockReadOnly, adCmdText
    Set ListHistoryForId = rst
    
    Exit Function
    
ErrorHandler:
    If Not rst Is Nothing Then Set rst = Nothing

    objContext.SetAbort
    Err.Raise Err.Number, "History.ListHistoryForId()", Err.Description

End Function
