I have the following function to return the lastflight for a give given battery in the flights table. Which it does. Except if there is no battery with that ID I still get a rs.record.count of one. And I think the count is one more than the number of records I see in the flights table. Also rs.bof and rs.eof are false. So why do I get one record more.
' Find last flight date for battery from Flights table
Public Function fFLightsBatteryLastDate(Batteryid)
Dim strSql As String
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = CurrentDb()
strSql = "Select flights.ifid,flights.iBatteryID,Flights.dDate,Flig hts.sMode "
strSql = strSql + " From Flights where iBatteryID=" & Batteryid
strSql = strSql + " Order by flights.dDate desc"
Debug.Print "fFlightsBattery=" & strSql
Set rs = db.OpenRecordset(strSql, dbOpenDynaset)
Debug.Print "rs.RecordCount=" & rs.RecordCount
Debug.Print "fFlights rs!dDate=" & rs!dDate
fFLightsBatteryLastDate = rs!dDate
glosMode = rs!sMode
Set rs = Nothing
Set db = Nothing