Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Help   Contact   Merch   Join   Order   Logon   Forums   
 
Back to Access Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Run rime Error 3021 No Current Record
Mubeezi Micah 

15 years ago
Dear Richard,

I have run into something all of a sudden. I can't believe it! My recordsets have been working perfectly until this evening.

I have a form that gives the user a program performance summary. On the current event of the form are several recordsets counting different categories of patients or treatment supporters. I paste one recordset below as example

Private Sub HowManyOccupiedPeers()
    Dim DB As Database
    Dim rs As Recordset
    Dim MySQL
    
    

    Dim W As String
    Dim s As String
    
    On Error Resume Next
    MySQL = " SELECT * FROM PeerEducatorsT WHERE TotalUnderCare  > 0 " 'summary of how many treatment supporters (Peer Educators) have TB patients to follow up
    

    Dim X
    
    Set DB = CurrentDb
    Set rs = DB.OpenRecordset(MySQL, dbOpenDynaset)
    
    On Error Resume Next
    rs.MoveLast
    X = rs.RecordCount
    X = Format(X, "00")
    
    
    PeersWithPatients = X
      
    rs.Close
    DB.Close
    
    Set rs = Nothing
    Set DB = Nothing
End Sub

These codes have been running perfectly until today when it gives me the above error. The VBA editor highlights the code rs.MoveLast.

Richard, how do i get around this without removing this summary form from the database? This form is very important in my database. It provides the users in the field a quick overview of the program performance in second.

Thank you,

MICAH


Reply from Richard Rost:

Check to make sure you HAVE records first before moving to the last one. If your recordset has 0 records, this error will occur. Try:

if rs.EOF then
   Peers = 0
else
   rs.MoveLast
   Peers = rs.RecordCount
end if

But of course this begs the bigger question: WHY are you using a recordset for this? You could probably do it easier with a single DCOUNT function.

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 8/7/2026 8:13:11 PM. PLT: 1s