Access 2000 has some significant design changes, as a result, unlike
previous versions, a database must be opened in Exclusive mode before
you can successfully make any design changes. Deleting an Access
specific object (Forms, Reports, Macros, and Modules etc.) in a database via
Automation code is considered a design change.
The OpenCurrentDatabase method allows you to specify an optional
argument which will force the database to be opened in exclusive mode.
You will need to modify your old code to include this argument.
Sub sDeleteOnA2K()
Const DB_NAME = "D:\office2000\Office\Samples\Northwind.mdb"
Dim objAcc As Access.Application
Set objAcc = New Access.Application
With objAcc
.Visible = True
.OpenCurrentDatabase DB_NAME, True
.DoCmd.DeleteObject acModule, "Module1"
.CloseCurrentDatabase
.Quit
End With
Set objAcc = Nothing
End Sub
|