ACC97- How to delete form in another database


Question

The problem is that I can't figure out the DAO needed to delete a form/report/script/module from a database, set as an object - i.e., not the current database. Any ideas? It seems I should use the Document object, but there is no Delete method on the Documents container.

Answer

From: Shamil Salakhetdinov <shamil@marta.darts.spb.ru>
To: Microsoft Access Database Discussion List <ACCESS-L@PEACH.EASE.LSOFT.COM>
Subject: Re: ACC97- How to delete form in another database
Date: 14 May 1998 0:41

Neil,

I hope this function is not only an answer to your question - it is also a general framework how to do a lot of tricky things using Access -> Access Automation:

Public Function smsDeleteObjectExt(ByVal vstrMdbPath As String, _
                                                      ByVal vlngObjectType As Long, _
                                                      ByVal vstrObjectName As String) As Boolean
    
    Dim objAcc As New Access.Application
    
    objAcc.OpenCurrentDatabase vstrMdbPath
    objAcc.DoCmd.DeleteObject vlngObjectType, vstrObjectName
    objAcc.CloseCurrentDatabase
    objAcc.Quit
    
    Set objAcc = Nothing
End Function

HOME    TOPICS

Copyright © 1998–1999 by Shamil Salakhetdinov.
All rights reserved. Terms of use.

Last updated: October 10, 2006

Published also here at 4TOPS: ACC97- How to delete form in another database