Results 1 to 7 of 7
  1. #1
    Join Date
    Apr 2002
    Posts
    2

    Exclamation Unanswered: [VB] recordset 3021

    I have got this

    Code:
    Set PC_Temp_Rec = PC_Db.OpenRecordset("SELECT * FROM DATA WHERE ClosureDate >= #" & _
    DTFrom.Value & "# AND ClosureDate <= #" & DTTill.Value & "# ORDER BY ProjectNumber")
    This works, because this will print out the numbers of the projects:
    Code:
    Do Until PC_Temp_Rec.EOF
    lbOutput.AddItem PC_Temp_Rec!ProjectNumber
    PC_Temp_Rec.MoveNext
    Loop
    But, I want to give 'out' the value of RS(0)
    Code:
    Set RS = PC_Db.OpenRecordset("SELECT COUNT(* ) FROM SCORE WHERE ProjectNumber = 
    '" & PC_Temp_Rec!ProjectNumber & "' AND Timeliness = 'N/A'")
    Out = RS(0)
    lbOutput.AddItem " Timeliness/Accessibility     " & Out
    This doesn't work. I get the 'Run time error 3021' No current record. Message.

    Can somebody help?

  2. #2
    Join Date
    Oct 2001
    Location
    Bay Area, CA
    Posts
    117
    Try:
    Out = RS.Fields(0)

    Hope this helps...

  3. #3
    Join Date
    Apr 2002
    Posts
    2

    Exclamation

    So I'm using now this code:

    Code:
    sQuery = "SELECT COUNT(*) As Teller FROM SCORE WHERE ProjectNumber = '" & PC_Temp_Rec.Fields("ProjectNumber") & "'AND Timeliness = 'N/A'"
        Set rst = PC_Db.OpenRecordset(sQuery)
        If Not rst.EOF Then
            iOut = rst.Fields("Teller")
            lbOutput.AddItem " Timeliness/Accessibility     " & iOut
        End If
    But I still get the 3021 error.

    Anybody an idea what that means?

  4. #4
    Join Date
    Nov 2001
    Posts
    336
    Try this:

    Set rst = PC_Db.OpenRecordset(sQuery)
    rst.movefirst

  5. #5
    Join Date
    Feb 2004
    Location
    India
    Posts
    22

    Re: [VB] recordset 3021

    I am also facing the same problem. I am using Oracle as backend...Does any body has solution? Please help me out.
    Regards,
    Jigar Bhavsar

  6. #6
    Join Date
    Apr 2004
    Location
    Derbyshire, UK
    Posts
    789
    Provided Answers: 1
    Access error code 3021 returns 'No current record' which would suggest the query does not have return records.

    (You can find this out by having 'MsgBox AccessError(3021) ' in a module sub and running it)

    Try checking if 'rs.BOF and rs.EOF' is true before trying to access the records !

    Hope this helps

    MTB

  7. #7
    Join Date
    Feb 2004
    Location
    India
    Posts
    22
    I have tried by giving alias name as well. But it still throws an error
    Regards,
    Jigar Bhavsar

Posting Permissions

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