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 
How to Automatically Insert Code Into Current Code
Tom Juric 
      
14 months ago
I am updating an old database with over 200 forms.  Most forms have multiple SUBs.  There is currently NO error checking.  I would like to INSERT "OnError GoTo" AND instructions to 1.Create and Error Message and 2. Store the message in a TEXT file. (I have this code, and it works great). Later the user can Email me the text file.

Does anyone know of any code or way to INSERT this code automatically where I do not have to scroll through each form and each SUB then paste the required data?
Tom Juric OP  @Reply  
      
14 months ago
I forgot this: I need this code to be INSERTED
   1: Part A at start of SUB
   2: Part B near end of SUB
Sami Shamma  @Reply  
             
14 months ago
Alex Hedley  @Reply  
           
14 months ago
You could VCS / GitHub to export all the code.
Write some PowerShell or VBA to add the code to all the Forms
Then recompile the db.
John Davy  @Reply  
         
14 months ago
Hi Tom
Is there a key word or key text at the point of insertion?  If so, you might do a search and replace with  Philipp Steifel's AccDev   HTH  Johnf
Tom Juric OP  @Reply  
      
14 months ago
John, I tried a search and replace on "()" which comes at the end of the SUB name, [Private Sub Form_Open()]
but could not find a way to ADD a line after the ().  I tried vbCfCr, ^p, Chr symbols in the REPLACE box but it would not work. If I could figure out a way to ADD the line in the Find/Replace box I could make this happen.  Here is the line of Code I need to ADD and what it should look like:

Private Sub Form_Open()
On Error GoTo err_pos

I will try the other two options later today
Matt Hall  @Reply  
          
14 months ago
You could write it like this.

Private Sub Form_Open(): On Error GoTo err_pos

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Developer 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/22/2026 1:18:03 AM. PLT: 0s