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 3048
Kyle Rapp 
    
2 years ago
Hey guys, I have been getting this error periodically.  "Can't connect to any more databases". The error description is inaccurate because I only have 1 database, so I think its referring to how many times I connect to a table in the same session.  Recently though, I started using some new code that always results in this error so I'm wondering if anyone is aware of a workaround.  Here is what I'm doing that results in the error:

I have a CustomerT and VehicleT, CustomerF and VehicleF.  Customers own 1 or more vehicles.  I have code that opens CustomerF with a where condition to filter the records in the form. Then, I open a report, filtering the report to show only the Customer record I'm on, print the report to fullname.PDF and then I loop through all customer records to do the same thing till I reach the end of the recordset. I can only create 165 PDFs before it fails.  (always 165 regardless of which 165 records) Any ideas?
Adam Schwanz  @Reply  
           
2 years ago
Are you closing your objects as you go?


While Not rs.EOF
    DoCmd.OpenForm "CustomerF", acNormal, , "CustomerID=" & rs!CustomerID
    DoCmd.OpenReport "CustomerReport", acViewPreview, , "CustomerID=" & rs!CustomerID
    DoCmd.OutputTo acOutputReport, "CustomerReport", acFormatPDF, "C:\Path\To\PDFs\" & rs!CustomerName & ".pdf"
    
    DoCmd.Close acReport, "CustomerReport"
    DoCmd.Close acForm, "CustomerF"
    rs.MoveNext
Wend


Can you open the report without opening the form? That would limit your objects drastically.

If nothing else, you can just do this in batches instead of one recordset.

Could you post your code to see what you have?
Kyle Rapp OP  @Reply  
    
2 years ago
Hi Adam, thanks for your help here.  So, I can open the report without opening the form but the issue is the report has all customers, so the reason I'm doing it by looping through the customer form is so I can grab the customer name and vehicle info to open the report, filter by the open customer record on the customer form and export each customer to their own PDF.  

Here is the code:

DoCmd.OpenForm "CustomerF", acNormal, , "CustomerStatus = 'Active' and ActiveVehicleCount >0"
Dim rs As dao.Recordset
Set rs = Forms!customerF.Recordset
rs.MoveFirst
Do While Not rs.EOF
DoCmd.OpenReport "WorkOrdersReport", acViewPreview, , "FullName = """ & Forms!CustomerF.FullName & """"
DoCmd.OutputTo acOutputReport, "WorkOrdersReport", acFormatPDF, "d:\docs\workorders\" _
& Forms!CustomerF.FullName & " - Worder Order.pdf", , , , acExportQualityPrint
DoCmd.Close acReport, "WorkOrdersReport", acSaveNo
rs.MoveNext
Loop
DoCmd.Close acForm, "CustomerF", acSaveYes
MsgBox "Done exporting, check your output folder."

Thanks in advance.
Kyle

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:24:00 AM. PLT: 1s