Runtime Error 3021 BOF EOF
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Runtime Error 3021 BOF EOF

  1. #1
    Join Date
    Dec 2010
    Posts
    5

    Unhappy Runtime Error 3021 BOF EOF

    Code:
    
    Call Opendbase
    rs.Open "Select * from tblBorrowedBooks where IDNumber = '" & txtID.Text & "' and BookTitle= '" & txttitle.Text & "' and Copies = " & BorrowedBooksGrid.TextMatrix(BorrowedBooksGrid.Row, 9) & "", cn, 3, 2
    If Not rs.BOF And rs.EOF Then
    rs!Copies = Val(copy.Text) + Val(txt.Text)
        BorrowedBooksGrid.Refresh
        rs.Update
        rs.Close
        cn.Close
        BorrowedBooksGrid.Refresh
        MsgBox "Book Borrowed. . . ."
        copy.Text = ""
        Else
        rs.MoveFirst '<---------Error Here il try to change it to movelast but the same error
     End If
    
    End If
    any BOF EOF solution syntax for my code help me plss
    i dont want to use error handler because nothing happen the program only bypass the Error pls help me guys

  2. #2
    DataMiser is offline Super Moderator Power Poster
    Join Date
    Jul 2008
    Location
    WV
    Posts
    4,823

    Re: Runtime Error 3021 BOF EOF

    Code:
    If Not rs.BOF And rs.EOF Then
    If both BOF and EOF is true as would be the case in your else senario then there are no records in the recordset therefore there is no first or last to move to and it is giving you an error.

    What you need in your else is something more like.

    Code:
    Msgbox "Record not found"


    Edit: On another note you should be closing your recordset outside the If block. as is it is only closing the recordset when the If condition is true. moving the close statement after the end if will close it in either case.
    Last edited by DataMiser; August 13th, 2011 at 09:02 AM.
    Always use [code][/code] tags when posting code.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center