[AccessD] Deleting an Entire Module Procedure via code

MartyConnelly martyconnelly at shaw.ca
Tue Mar 18 03:32:40 CST 2003


John Bartow wrote:

>Hi Bryan,
>A97, I just wanted to delete one procedure.
>
>I was just checking to see if anyone had code that I could adapt and also if
>there were any methods that worked/didn't work well. (I have never
>manipulated module code with code before so I wanted to check first.)
>
>John
>
>-----Original Message-----
>From: accessd-admin at databaseadvisors.com
>[mailto:accessd-admin at databaseadvisors.com]On Behalf Of Bryan Carbonnell
>Sent: Monday, March 17, 2003 9:18 PM
>To: accessd at databaseadvisors.com
>Subject: Re: [AccessD] Deleting an Entire Module Procedure via code
>
>
>On 17 Mar 2003 at 15:46, John Bartow wrote:
>
>  
>
>>Anyone have advice on deleting an entire module procedure via code?
>>    
>>
>
>John,
>
>What version of Access?
>
>Do you want to delete a complete module or just a procedure?
>
>--
>Bryan Carbonnell - carbonnb at sympatico.ca
>I'm not a complete idiot some parts are missing.
>
>
>
>  
>
I suppose you could also use the brute force method below and parse the 
output text file cutting the procedure and reload it. To bad you can't 
use Memory Mapped Files as a virtual file.


Public Sub DocDatabase()
'====================================================================
' Name: DocDatabase
' Purpose: Documents the database to a series of text files
'
'
' Comment: Uses the undocumented [Application.SaveAsText] syntax
' To reload use the syntax [Application.LoadFromText]
'====================================================================
On Error GoTo Err_DocDatabase
Dim dbs As Database
Dim cnt As Container
Dim doc As Document
Dim i As Integer

Set dbs = CurrentDb() ' use CurrentDb() to refresh Collections

Set cnt = dbs.Containers("Forms")
For Each doc In cnt.Documents
Application.SaveAsText acForm, doc.Name, "D:\Document\" &
doc.Name & ".txt"
Next doc

Set cnt = dbs.Containers("Reports")
For Each doc In cnt.Documents
Application.SaveAsText acReport, doc.Name, "D:\Document\" &
doc.Name & ".txt"
Next doc

Set cnt = dbs.Containers("Scripts")
For Each doc In cnt.Documents
Application.SaveAsText acMacro, doc.Name, "D:\Document\" &
doc.Name & ".txt"
Next doc

Set cnt = dbs.Containers("Modules")
For Each doc In cnt.Documents
Application.SaveAsText acModule, doc.Name, "D:\Document\" &
doc.Name & ".txt"
Next doc

For i = 0 To dbs.QueryDefs.Count - 1
Application.SaveAsText acQuery, dbs.QueryDefs
(i).Name, "D:\Document\" & dbs.QueryDefs(i).Name & ".txt"
Next i

Set doc = Nothing
Set cnt = Nothing
Set dbs = Nothing

Exit_DocDatabase:
Exit Sub


Err_DocDatabase:
Select Case Err

Case Else
MsgBox Err.Description
Resume Exit_DocDatabase
End Select

End Sub


'in clean database load the new form
Public Function LoadForm(frm As String)
On Error Resume Next

Application.LoadFromText acForm, frm, "D:\YourPath\" & frm & ".txt"

End Function




More information about the AccessD mailing list