Results 1 to 5 of 5
  1. #1
    Join Date
    Nov 2002
    Location
    Belgium
    Posts
    243

    Unanswered: Recordset-problem

    I have a problem using a RecordSet.
    I already used it several times without any problem, and now it won't work.

    I used following code :

    *********************************

    Dim rs as New ADODB.RecordSet

    rs.open "SELECT relatedFunctionID FROM tblCourses WHERE CoursID = 122", CurrentProject.Connection, adOpenDynamic

    For teller = 0 tot rs.Fields.Count - 1
    Debug.Print rs.Fields(teller)
    Next teller

    rs.Close

    *********************************

    I always get an error wich says BOF or EOF is True .....

    Any ideas ?
    Last edited by artemide; 04-15-03 at 08:54.

  2. #2
    Join Date
    Oct 2001
    Location
    Chicago
    Posts
    440
    Works fine on my PC.

    Are you sure that you have a CoursID = 122

    Also you should have some level of protection from an empty recordset.

    If rs.RecordCount > 0 Then
    For teller = 0 To rs.Fields.Count - 1
    Debug.Print rs.Fields(teller)
    Next teller
    Else
    Debug.Print "No records"
    End If

    Matt

  3. #3
    Join Date
    Nov 2002
    Location
    Belgium
    Posts
    243

    Recordset-problem

    I do have a courseID = 122.
    When I put my query in the Acces QueryDesigner it gives me a resultset of 3 records.
    Even when I
    Debug.Print rs.Fields.Count
    then it gives me 3 as the result.
    But printing each item fails.

    The exact error-message is :
    -----------------------------------------------------------------------
    Error 3021:
    Either BOF or EOF is true, or the current record has been deleted.
    Requested operation requires a current record.
    -----------------------------------------------------------------------

    I put this piece of code before getting this error :
    ************************************************** *
    If rs.BOF
    Then Debug.Print "BOF = True"
    Else Debug.Print "BOF = False"
    ************************************************** *

    Did the same for EOF and guess what : they both are TRUE.
    How is this possible and how can I solve this ?


    Last edited by artemide; 04-16-03 at 04:07.

  4. #4
    Join Date
    Dec 2002
    Location
    Glasgow, UK
    Posts
    100
    this may help (or may not !!)

    When I open a recordset I always add "rs.movefirst" just to be sure that I'm at the start of the recordset.

  5. #5
    Join Date
    Nov 2002
    Location
    Belgium
    Posts
    243
    Originally posted by xander
    this may help (or may not !!)

    When I open a recordset I always add "rs.movefirst" just to be sure that I'm at the start of the recordset.
    I already tried that, but it didn't work either.
    I started all over again and rebuild and debugged the code step by step and now I got it working.
    I still don't know the reason, but at least it's running.

    Thanks for your help.

Posting Permissions

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