Error number 3021 (1 Viewer)

exaccess

Registered User.
Local time
Today, 18:19
Joined
Apr 21, 2013
Messages
287
Hello Experts,
I was almost finished coding a rather complicated module when I started getting this Error Number 3021. I looked around. It has something to do with the recordsets I am using but what. I cannot find. Could somebody help please? Many thanks.
 

JHB

Have been here a while
Local time
Today, 18:19
Joined
Jun 17, 2012
Messages
7,732
It seems to be no current record.
Show you code + where (code line) + when you get the error.
 

exaccess

Registered User.
Local time
Today, 18:19
Joined
Apr 21, 2013
Messages
287
It seems to be no current record.
Show you code + where (code line) + when you get the error.
Code:
Public ch As Recordset
Dim fld As String, Tline As String, Logger As String, Fbuffer As String, tot As Double
    Dim rr As Recordset, RT As Recordset
    Dim db As Database
    Set db = CurrentDb
'-----------------------------------------------------------------------------------
'   Clear the target table
'-----------------------------------------------------------------------------------
    DoCmd.SetWarnings False
    DoCmd.RunSQL "DELETE * FROM TargetTbl"
    DoCmd.SetWarnings True
'-------------------------------------------------------------------------------------------
'   Define and set recordsets
'--------------------------------------------------------------------------------------------
    Set rr = db.OpenRecordset("OriginalTbl")
    Set RT = db.OpenRecordset("TargetTbl")
    Set ch = db.OpenRecordset("SearchingTbl")
'----------------------------------------------------------------------------------------------
'   get the highest total value to use in calculations
'----------------------------------------------------------------------------------------------
    ch.MoveFirst
    Do While Not ch.EOF
        If ch.Fields("Action").Value = "9" Then
            tot = CDbl(ch.Fields("SearchTerm").Value)
            Debug.Print "tot="; tot
            Exit Do
        Else
            ch.MoveNext
        End If
    Loop
'----------------------------------------------------------------------------------------------
'   Set record counters
'----------------------------------------------------------------------------------------------
    IR = 0
    IT = 0
    IK = 0
    rr.MoveFirst
    RT.MoveFirst
It breaks exactly at this point.
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 17:19
Joined
Sep 12, 2006
Messages
15,634
if rt has no records then rt.movefirst will error with exactly the error you get - no current record

should it have records? if you are inserting records into rt, then you do not need to reposition the file pointer for rt.

simply

Code:
 rt.addnew
 rt!fieldname = whatever   'easier syntax than rt.field("fieldname")
 rt.update
 

exaccess

Registered User.
Local time
Today, 18:19
Joined
Apr 21, 2013
Messages
287
if rt has no records then rt.movefirst will error with exactly the error you get - no current record

should it have records? if you are inserting records into rt, then you do not need to reposition the file pointer for rt.

simply

Code:
 rt.addnew
 rt!fieldname = whatever   'easier syntax than rt.field("fieldname")
 rt.update
I deleted RT.MoveFirst and it works. Thank you.
 

exaccess

Registered User.
Local time
Today, 18:19
Joined
Apr 21, 2013
Messages
287
if rt has no records then rt.movefirst will error with exactly the error you get - no current record

should it have records? if you are inserting records into rt, then you do not need to reposition the file pointer for rt.

simply

Code:
 rt.addnew
 rt!fieldname = whatever   'easier syntax than rt.field("fieldname")
 rt.update

I deleted RT.MoveFirst and it works. Thank you.
 

Users who are viewing this thread

Top Bottom