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 
Runtime Error 91
James Hopkins 
     
5 months ago
Hey Richard and the Guys, I have created an Function that generates Future Invoice Dates for sent out Emailed or Printed Invoices on a Scheduled Date. The problem that I had ran into is when running the Code, I get a Runtime Error '91' on "rs.Close". Any help on this Error.
James Hopkins OP  @Reply  
     
5 months ago

James Hopkins OP  @Reply  
     
5 months ago

Donald Blackwell  @Reply  
       
5 months ago
can you show us the code where you set rs?

it's basically saying that it's not seeing where rs was initialized.
Donald Blackwell  @Reply  
       
5 months ago
For example, if your "set rs = db.openrecordset"... is inside your loop, you'll need to close it inside the loop, or if it was set inside an if/then statement block, then it may not have gotten set for a particular instance.
James Hopkins OP  @Reply  
     
5 months ago

James Hopkins OP  @Reply  
     
5 months ago

Donald Blackwell  @Reply  
       
5 months ago
I would move the rs.close and rsdetail.close statements into the loop right before "next" since they are set near the beginning of the loop.
Sandra Truax  @Reply  
         
5 months ago
I may be overlooking it, but did you "Set rs = Nothing"?
Kevin Robertson  @Reply  
          
5 months ago
Sandra Look at an earlier image (the one with rs.Close highlighted).
James Hopkins OP  @Reply  
     
5 months ago
Sorry about that.
James Hopkins OP  @Reply  
     
5 months ago

James Hopkins OP  @Reply  
     
5 months ago

James Hopkins OP  @Reply  
     
5 months ago
Sandra, Yes, I set the rs=Nothing details enclosed.
James Hopkins OP  @Reply  
     
5 months ago
Donald, I tried move rs.Close and rsDetail.Close before the Next i, in the Code. But I still get a Error Message. I looked around and through the Code and have not seen everything that would create this Error Message, cause I use a similar Code in other Forms to Schedule or Generate Future Dates.
Kevin Robertson  @Reply  
          
5 months ago
You are missing .Form in the Subform references.

Value From Subform
James Hopkins OP  @Reply  
     
5 months ago
Hey Kevin, I went back to the Code and fix the Subform .Form for the Fields need the be inserted into the Future Invoices. But I am still get the same error message.
Donald Blackwell  @Reply  
       
5 months ago
Hi James, just thinking (typing) out loud...

1) You're declaring your recordsets on each iteration of the loop(s). Is that necessary since you're just opening each to a table to add records, might it be more efficient just to open each before going into your loop for example:

Details     Set db = CurrentDb
     Set rs = db.OpenRecordset("RecurringInvoiceT")
     Set rsDetail = db.OpenRecordset("RecurringInvoiceTemplateDetailT")

     ' Loop through each Future Recurring Invoices
     For i = 1 to CountRecInvoice
...


Then your "rs.close" and "rsDetail.close" could be outside of the loop like you originally had it without any issues.

2) As I was looking at the above "set rs..." and "set rsDetail..." placement I noticed that you DID Dim "CountRecInvoice", however, you never assigned a value to it. So your loop is never running to declare the rs and rsDetail because it essentially reads "For i = 1 to 0"

So, I think, regardless of whether you apply suggestion 1, you'll not see any change until you address # 2.

Hope this helps. Don
James Hopkins OP  @Reply  
     
5 months ago
Thank Donald, I find got it. You was correct thanks again.

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/7/2026 11:22:18 AM. PLT: 0s