nil RecordSet test for record not found

sSQL = "SELECT * FROM Contacts WHERE ContactID = '" + sContactID + "'" rsTemp = dbSQL.SQLSelect(sSQL) if rsTemp <> Nil then MsgBox("The ContactID supplied is in use, select a different ContactID") tfContactID.SetFocus Return end if

I have the above code in the LostFocus event of the a TextField for ContactID which must be unique and between 4 and 12 characters. I am testing the code and putting a value of “TEST” in the ContactID field. There is NO record in the table with a value of “TEST” in ContactID. Yet rsTemp is NOT nil but has a row with nil in all fields. So it didn’t find a row but it still isn’t nil. what am I doing wrong?


What that tells you is the recordset is empty meaning there are no matching rows

You only get a nil recordset if the query is invalid