Results 1 to 4 of 4
  1. #1
    3 Star Lounger
    Join Date
    Jul 2001
    Posts
    280
    Thanks
    0
    Thanked 0 Times in 0 Posts

    delete a module from another database (Access 2000)

    Delete a module from another database

    i have the following function that deletes a tables from another database:

    Public Function FncRemote
    Dim cat As New ADOX.Catalog, objConn As New ADODB.Connection
    objConn.Open "Provider= Microsoft.Jet.OLEDB.4.0;Data Source = C:bestorebe.mdb"
    With cat
    .ActiveConnection = objConn
    .Tables.Delete "products"
    End With
    End Function

    Howver the above function works with tables only and not with modules, or forms.
    Is there any way to delete a module or a form from another database?

  2. #2
    Lounger
    Join Date
    Oct 2001
    Location
    Upper NY State, USA
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: delete a module from another database (Access 2000)

    You could create and open hidden a "Delete" Form on the remote db via code. On the OnOpen event of the form you could use the DeleteObject method on acForm or acModule. The parameters could be passed to the remote db into a special table with a ObjectType column and an Object Name column.

    I know it's a real Rube Goldberg idea, but that's what I seem to excel at when under the gun.

    Dave Mack <img src=/S/nuts.gif border=0 alt=nuts width=15 height=15>

  3. #3
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: delete a module from another database (Access 2000)

    You have to keep in mind that ADO is designed to access data. The OLEDB provider doesn't really know much about the object structure of the data source, even when it's the Jet OLE DB provider. DAO was designed to work with Jet, ADO is designed to work with data and there are objects and properties and methods it can't even see unless the OLE DB provider makes them available.
    Charlotte

  4. #4
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    1,862
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: delete a module from another database (Access 2000)

    To answer your question: Yes. You have to use OLE Automation code. This isn't too difficult, especially since you don't have to worry about adding extra libraries for other applications. Here's a sample that should work for you:<pre>Sub DeleteModule()
    Dim appAccess As Access.Application
    Set appAccess = CreateObject("Access.Application")
    'Replace database file and path with your own
    appAccess.OpenCurrentDatabase "D:My DocumentsYourDatabase.mdb", True
    appAccess.DoCmd.DeleteObject acModule, "YourModule" 'Replace with your module's name
    appAccess.Quit
    Set appAccess = Nothing
    End Sub</pre>

    You'll have to change the database path and name along with the module name to make this work.
    HTH <img src=/S/salute.gif border=0 alt=salute width=15 height=20>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •