DoCmd DeleteObject A_MODULE, "ModuleName" does not work in VB for v2.0. Does anyone know a workaround. (Someone asked the exact same question about 3 years ago with no response.)
From: Shamil Salakhetdinov <shamil@marta.darts.spb.ru>
To: ACCESS-L <ACCESS-L@PEACH.EASE.LSOFT.COM>
Subject: Re: v2.0 - DeleteObject A_MODULE
Date: 16 июля 1998 г. 1:23
Enclosed you find the functions I wrote about three years ago. I used them in my MS Access 2.0 Builds Coordination Utility, I found that
to be able to delete modules you have to write some code and three macros:
As far as I can remember you can delete modules in MS Access 2.0 if and only if you do this using macro as entry (starting) point, i.e. you cannot runmacro from module to delete another modules but you can runmacro (cycled) which uses functions used to prepare macros to delete modules... ;-) Probably I missed something and there is a simpler way but this tricky solution worked OK.
HTH,
Shamil
P.S. The code:
Function crSetRepeatCount ()
On Error GoTo crSetRepeatCount_Err
Dim db As Database, rec As Recordset
Dim intObjectType As Integer, strObjectName As String
Set db = dbengine(0)(0)
Set rec = db.OpenRecordset("MSYSMacros", DB_OPEN_DYNASET)
If Not rec.eof Then
rec.FindFirst "[Scriptname] = """ & "~crmcrFindAndDeleteObjectShell" & """"
If Not rec.nomatch Then
rec.MoveNext
rec.Edit
rec![Argument2] = crQtyOfObjectsToDelete()
rec.Update
End If
End If
crSetRepeatCount = True
crSetRepeatCount_Done:
Exit Function
crSetRepeatCount_Err:
crShowStopErrMsg "crSetRepeatCount"
Resume crSetRepeatCount_Done
End Function
Function crChangeObjectToDelete ()
On Error GoTo crChangeObjectToDelete_Err
Dim db As Database, rec As Recordset
Dim intObjectType As Integer, strObjectName As String
Set db = dbengine(0)(0)
Set rec = db.OpenRecordset("MSYSMacros", DB_OPEN_DYNASET)
If Not rec.eof Then
rec.FindFirst "[Scriptname] = """ & "~crmcrDeleteObjectInCrMdb" & """"
If Not rec.nomatch Then
rec.MoveNext
rec.Edit
crNextObjectToDeleteFromCrMdb intObjectType, strObjectName
rec![Argument1] = intObjectType
rec![Argument2] = strObjectName
rec.Update
End If
End If
crChangeObjectToDelete = True
crChangeObjectToDelete_Done:
Exit Function
crChangeObjectToDelete_Err:
crShowStopErrMsg "crChangeObjectToDelete"
Resume crChangeObjectToDelete_Done
End Function
Sub crNextObjectToDeleteFromCrMdb (intObjectType As Integer, strObjectName As String)
Dim dbCurr As Database, rec As Recordset, strrecSql As String
Set dbCurr = dbengine(0)(0)
Set rec = dbCurr.OpenRecordset("~crqselNextObjectToDelete", DB_OPEN_DYNASET)
If Not rec.eof Then
rec.MoveFirst
intObjectType = rec!ObjectType
strObjectName = rec![Name]
rec.Edit
rec!DeleteMeFromCrMdb = False
rec.Update
End If
End Sub
| HOME TOPICS |
Copyright © 19951999 by Shamil Salakhetdinov.
|
| Last updated: October 10, 2006 | |