Question

Help my code got wrong it says:

Either BOF or EOF is True, or the current record has been deleted,Requested operation requires a current record.

i think this rs.close has a problem or where can i set the rs.close? because i set and used recordset twice. anyone can help? please fix my code.



Public Function borrowersName(ByVal Iname, ByVal Imod, ByVal Icat, ByRef BFname, ByRef BLname) As Boolean

Dim dateReturned As String

'select firt the primary key of the item
qry1 = "select tblitem_id from tblitem inner join tblcategory on tblitem.tblcategory_id=tblcategory.tblcategory_id where tblitem.item_name='" + Iname + "' and tblitem.item_model='" + Imod + "' and tblcategory.category_name='" + Icat + "'"
rs.Open qry1, conn
qry1Result = rs.Fields(0).Value
rs.Close

qry2 = "SELECT date_returned,Firstname,Lastname FROM tblborrowers where tblitem_id='" & qry1Result & "' ORDER BY tblborrowers_id DESC LIMIT 1"
rs.Open qry2, conn

dateReturned = rs.Fields(0).Value

If dateReturned <> "" Then
  borrowersName = True
  BFname = rs.Fields(1).Value
  BLname = rs.Fields(2).Value
Else
  borrowersName = False
End If

Set rs = Nothing

End Function

Was it helpful?

Solution

You do have the recordset Open and Close methods in the right order, so there is no problem there.

The error "Either BOF or EOF is True, or the current record has been deleted" simply means that one of your SELECT queries has returned zero records. What you do about that depends on your requirements. For example, you could test for Not rs.EOF before attempting to read a field value.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top