![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I want to include a single new line of code in the Activate event in each form in my application (180 forms). Rather than open each manually, I was hoping there might be a way to use the documents and modules collection to open each class module and edit it using VBA. Has anyone tried this? I'm using Access 2002. -- Bob Darlington Brisbane |
#3
| |||
| |||
|
|
"Bob Darlington" <bob (AT) notheredpcman (DOT) com.au> wrote in message news:4cc0e029$0$25481$afc38c87 (AT) news (DOT) optusnet.com.au... I want to include a single new line of code in the Activate event in each form in my application (180 forms). Rather than open each manually, I was hoping there might be a way to use the documents and modules collection to open each class module and edit it using VBA. Has anyone tried this? I'm using Access 2002. -- Bob Darlington Brisbane Public Sub TestEventCreate() Dim item As Variant, i As Long For Each item In CurrentProject.AllForms DoCmd.OpenForm item.Name, acDesign With Forms(0).Module i = .CreateEventProc("Activate", "Form") .ReplaceLine i + 1, "'A comment" End With DoCmd.Close acForm, item.Name Next End Sub That will open all forms in design view, create an Activate event and insert a comment in it. Replace the comment to insert the code you need. This code assumes it's running in a standard module and that there are no open forms. Caution - untested air code. Backup first. Adding to Stuart's reply, go to Help. Search for "module object". Then |
#4
| |||
| |||
|
|
"Bob Darlington" <bob (AT) notheredpcman (DOT) com.au> wrote in message news:4cc0e029$0$25481$afc38c87 (AT) news (DOT) optusnet.com.au... I want to include a single new line of code in the Activate event in each form in my application (180 forms). Rather than open each manually, I was hoping there might be a way to use the documents and modules collection to open each class module and edit it using VBA. Has anyone tried this? I'm using Access 2002. -- Bob Darlington Brisbane Public Sub TestEventCreate() Dim item As Variant, i As Long For Each item In CurrentProject.AllForms DoCmd.OpenForm item.Name, acDesign With Forms(0).Module i = .CreateEventProc("Activate", "Form") .ReplaceLine i + 1, "'A comment" End With DoCmd.Close acForm, item.Name Next End Sub That will open all forms in design view, create an Activate event and insert a comment in it. Replace the comment to insert the code you need. This code assumes it's running in a standard module and that there are no open forms. Caution - untested air code. Backup first. |
#5
| |||
| |||
|
|
Stuart McCall wrote: "Bob Darlington" <bob (AT) notheredpcman (DOT) com.au> wrote in message news:4cc0e029$0$25481$afc38c87 (AT) news (DOT) optusnet.com.au... I want to include a single new line of code in the Activate event in each form in my application (180 forms). Rather than open each manually, I was hoping there might be a way to use the documents and modules collection to open each class module and edit it using VBA. Has anyone tried this? I'm using Access 2002. -- Bob Darlington Brisbane Public Sub TestEventCreate() Dim item As Variant, i As Long For Each item In CurrentProject.AllForms DoCmd.OpenForm item.Name, acDesign With Forms(0).Module i = .CreateEventProc("Activate", "Form") .ReplaceLine i + 1, "'A comment" End With DoCmd.Close acForm, item.Name Next End Sub That will open all forms in design view, create an Activate event and insert a comment in it. Replace the comment to insert the code you need. This code assumes it's running in a standard module and that there are no open forms. Caution - untested air code. Backup first. Adding to Stuart's reply, go to Help. Search for "module object". Then look at the methods; Find, ReplaceLine, InsertLines, InsertText, CreateEventProc, etc. Most if not all have code examples. You might want to do this only for form's that currently have an event, perhaps an event with specific text. |
![]() |
| Thread Tools | |
| Display Modes | |
| |