Public Function GetPathLength(pathID As Variant) As Long
If Not IsNull(pathID) Then GetPathLength = Nz(DLookup("length", "qryPathLengths", "pathid_FK = " & pathID), 0)
End Function
Public Function GetPathDuration(pathID As Variant) As Long
If Not IsNull(pathID) Then GetPathDuration = Nz(DLookup("TotalDuration", "qryPathSummary", "pathid = " & pathID), 0)
End Function
Public Function GetPiggyBackWait(pathID As Variant) As Long
'both driver and passenger wait times
If Not IsNull(pathID) Then GetPiggyBackWait = Nz(DLookup("waitTime", "qryWaitTimeOnPath", "pathid_FK = " & pathID), 0)
End Function
Public Function GetNumberOfTripsOnPath(pathID As Variant) As Integer
If Not IsNull(pathID) Then GetNumberOfTripsOnPath = DCount("*", "tblPathTrips", "pathid_FK = " & pathID)
End Function
Public Function GetEndingTrip(pathID As Variant) As Long
Dim strSql As String
Dim rs As DAO.Recordset
If Not IsNull(pathID) Then
strSql = "Select top 1 TripID from qryPathTrips where PathID_FK = " & pathID & " order by TripID Desc"
Set rs = CurrentDb.OpenRecordset(strSql)
If Not rs.EOF Then GetEndingTrip = rs!tripID
End If
End Function
Public Function GetEndingEdge(pathID As Variant) As Long
Dim strSql As String
Dim rs As DAO.Recordset
If Not IsNull(pathID) Then
strSql = "Select top 1 EdgeID from qryPathTrips where PathID_FK = " & pathID & " order by TripID Desc"
Set rs = CurrentDb.OpenRecordset(strSql)
If Not rs.EOF Then GetEndingEdge = rs!EdgeID
End If
End Function
Public Function GetEndingVertex(pathID As Variant) As Long
Dim endingEdge As Long
Dim strSql As String
Dim rs As DAO.Recordset
If Not IsNull(pathID) Then endingEdge = GetEndingEdge(pathID)
If Not endingEdge = 0 Then
strSql = "Select top 1 EndVertex from qryPathTrips where PathID_FK = " & pathID & " order by TripID Desc"
'Debug.Print strSql & " problem"
Set rs = CurrentDb.OpenRecordset(strSql)
If Not rs.EOF Then GetEndingVertex = rs!EndVertex
End If
End Function
Public Function GetDriverFromPath(pathID As Variant) As Long
If Not IsNull(pathID) Then
GetDriverFromPath = Nz(DLookup("driverID", "tblcarShippingPaths", "pathID = " & pathID), 0)
End If
End Function
Public Function GetPiggyBackDriver(pathID As Variant, EdgeID As Variant) As Long
Dim CurrentDriver As Long
If Not IsNull(pathID) And Not IsNull(EdgeID) Then
CurrentDriver = GetDriverFromPath(pathID)
If CurrentDriver <> 0 Then GetPiggyBackDriver = Nz(DLookup("driverID", "qrySelectPiggyback", "edgeID_FK = " & EdgeID & " AND driverID <> " & CurrentDriver), 0)
End If
End Function
Public Function GetPiggyBackTrip(pathID As Variant, EdgeID As Variant) As Long
Dim CurrentDriver As Long
If Not IsNull(pathID) And Not IsNull(EdgeID) Then
CurrentDriver = GetDriverFromPath(pathID)
If CurrentDriver <> 0 Then GetPiggyBackTrip = Nz(DLookup("tripID", "qrySelectPiggyback", "edgeID_FK = " & EdgeID & " AND driverID <> " & CurrentDriver), 0)
End If
End Function
Public Function GetNumberAvailablePiggybacks(pathID As Variant, EdgeID As Variant) As Long
Dim CurrentDriver As Long
If Not IsNull(pathID) And Not IsNull(EdgeID) Then
CurrentDriver = GetDriverFromPath(pathID)
If CurrentDriver <> 0 Then GetNumberAvailablePiggybacks = DCount("*", "qrySelectPiggyback", "edgeID_FK = " & EdgeID & " AND driverID <> " & CurrentDriver)
End If
End Function
Public Function GetTotalDeliveredFromPath(pathID As Variant) As Long
If Not IsNull(pathID) Then
GetTotalDeliveredFromPath = Nz(DLookup("SumOfCarsShipped", "qryTotalShippedPiggyBackByPath", "pathID_FK = " & pathID), 0)
End If
End Function
Public Function GetTotalPiggyBacksFromPath(pathID As Variant) As Long
If Not IsNull(pathID) Then
GetTotalPiggyBacksFromPath = Nz(DLookup("SumOfPiggyback", "qryTotalShippedPiggyBackByPath", "pathID_FK = " & pathID), 0)
End If
End Function
Public Function GetTotalPassengersFromPath(pathID As Variant) As Long
If Not IsNull(pathID) Then
GetTotalPassengersFromPath = DCount("*", "qryPiggyBackData", "DriverPath = " & pathID)
End If
End Function
Public Function GetNextDriver() As Long
GetNextDriver = Nz(DLookup("driverID", "qryNextDriver"), 0)
End Function
Public Function GetStartVertexFromEdge(EdgeID As Long) As Long
GetStartVertexFromEdge = Nz(DLookup("startVertex", "tblCarShippingEdges", "EdgeID = " & EdgeID))
End Function
Public Function GetEndVertexFromEdge(EdgeID As Long) As Long
GetEndVertexFromEdge = Nz(DLookup("EndVertex", "tblCarShippingEdges", "EdgeID = " & EdgeID))
End Function