Run-time error '3021' - No Current Record. (1 Viewer)

Ashfaque

Student
Local time
Today, 09:42
Joined
Sep 6, 2004
Messages
894
Hi,

Set rst1 = CurrentDb.OpenRecordset("Select WeightInKgPerBag, totalbags from tbl_grouping_Mar")
rst1.MoveFirst

...furter code works well if there are records available in the tbl.

When there is no record in the table, it produces Run-time error '3021' - No Current Record.

How can I come out of this?

Please help.

Thnx
 

bob fitz

AWF VIP
Local time
Today, 05:12
Joined
May 23, 2011
Messages
4,726
Try:
Code:
If not rst1.EOF Then
[B]rst1.MoveFirst[/B]
 
...furter code works well if there are records available in the tbl.
 
EndIf
 

Ashfaque

Student
Local time
Today, 09:42
Joined
Sep 6, 2004
Messages
894
Thanks Bob,

It worked at one place and when I used similar trick in another code, it produce Circular Reference Warning.....may be something wrong in my code. I will have to recheck....
 

Ashfaque

Student
Local time
Today, 09:42
Joined
Sep 6, 2004
Messages
894
Attached is the warning...appearing after execution of code

Thanks,
 

Attachments

  • Circular Ref Warning.jpg
    Circular Ref Warning.jpg
    56.7 KB · Views: 613

Ashfaque

Student
Local time
Today, 09:42
Joined
Sep 6, 2004
Messages
894
Thanks Bob,

I traced out and working smoothly. The END IF was required to place at very end of code lines.

Regards,
Ashfaque
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 05:12
Joined
Sep 12, 2006
Messages
15,656
generally, this loops round all items.

Code:
set rst=currentdb.openrecordset("some query")
 
while not rst.eof
process item
rst.movenext
wend
 
rst.close
 

Users who are viewing this thread

Top Bottom