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 Developer Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Add Code to All Forms and Reports
Tom Juric 
     
30 days ago
I inherited a program to get it fixed. I have my own on_error code that writes the error to a text file and shows the form and error. I have already done this manually on a few of the forms, but I have a lot of forms left.

Is there a way to add code to two separate locations in the current code for all forms/reports? The new code needs to be inserted (1) on the line after Private Sub... [1xLine only], and (2) Immediately before the End Sub [4xLines of code]

Does anyone have any ideas?
Richard Rost  @Reply  
          
30 days ago
You can programmatically loop thru all of modules and form modules in the database and add/edit their code. I don't know how to do it from memory, but I'm sure GPT can help with some code. Don't think I covered it in any videos - pretty advanced stuff.

If you've got the same PIECE of code in every database, like "Open Explicit" you could do a global search and replace to add stuff after that. So you'd change that to "Option Explicit [NEWLINE] Private Sub..."
Kevin Robertson  @Reply  
           
30 days ago
Richard You already have a video that shows how to do this.

Find Replace VBA (Extended Cut)
Richard Rost  @Reply  
          
30 days ago
Well there ya go. :)

Thanks, Kevin
Add a Reply Upload an Image
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 8:34:16 AM. PLT: 0s