Home  |   French  |   About  |   Search  | mvps.org  

What's New
Table Of Contents
Credits
Netiquette
10 Commandments 
Bugs
Tables
Queries
Forms
Reports
Modules
APIs
Strings
Date/Time
General
Downloads
Resources
Search
Feedback
mvps.org

In Memoriam

Terms of Use


VB Petition

Bugs: Access 2000: DeleteObject code doesn't work

Author(s)
Dev Ashish
  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.

'********* Code Start *********
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
'********** Code End **********

© 1998-2010, Dev Ashish & Arvin Meyer, All rights reserved. Optimized for Microsoft Internet Explorer