Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Edit Recordset not executing
Sami Shamma 
             
3 years ago
Good morning friends:
I wrote a simple end of month Form to set a field on table to "IsClosed".
simple 2 loops. The first loop fires correctly; however, the second loop is not firing at all. I can't see where i am going wrong.

Here is the code. and the results are in the image below.

DetailsPrivate Sub CloseBtn_Click()
    
    Dim db As Database
    Dim rsY As Recordset    'YearMonthT
    Dim rsC As Recordset    'ChatT
    Dim rsA As Recordset    'AssT
    Dim S As String         'Select string with Year
    Dim S2 As String        'Select string with month
    Dim S3 As String        'Select string ChapT
    StatusBox = ""
    Status "-----------starting---------"
    
    Set db = CurrentDb
    S = "SELECT * From S_YearMonthT WHERE YMYear = """ & YearCombo & """"
    S2 = " And YMMonth = """ & MonthCombo & """"
    S = S & S2
    Set rsY = db.OpenRecordset(S)
    While Not rsY.EOF
        S3 = "SELECT * FROM ChapT WHERE YearMonthID = " & rsY!YearMonthID
        Status S3
        Status rsY!YMYear & " " & rsY!YMMonth
        Set rsC = db.OpenRecordset(S3)
        While Not rsC.EOF
            Status "YearMonthID = " & rsC!YearMonthID
            rsC.Edit
            rsC!IsClosed = True
            rsC.Update
            rsC.MoveNext
        Wend
        Status "end of rsC loop"
        rsY.MoveNext
    Wend
        Status "End of  rsY loop"
    rsC.Close
    db.Close
    Set rsC = Nothing
    Set db = Nothing

End Sub
Sami Shamma OP  @Reply  
             
3 years ago

Sami Shamma OP  @Reply  
             
3 years ago

Mischa Graafmans  @Reply  
    
3 years ago
Hello Sami Shamma, Can you share some data as well?
Looks like there is no data in your second loop hence it is skipping it.
Sami Shamma OP  @Reply  
             
3 years ago
Mischa,
Thank you for pointing me in the correct direction.  It was data problem. The code is working just fine.
Many thanks

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: 5/6/2026 11:20:34 AM. PLT: 1s