Search code examples
vb.netms-accessado.netoffice-automation

Delete a report from an mdb file without using automation


I know that I can delete a report from within Access VBA:

DoCmd.DeleteObject acReport, "SomeReport"

I also know that I can delete a report from outside Access by using automation (VB.NET example):

Set acc = CreateObject("Access.Application")
acc.OpenCurrentDatabase(...)
Set db = acc.CurrentDb()

' Enumerate db.Containers("Reports").Documents to find the report name
...

acc.DoCmd.DeleteObject(acReport, reportName)

I also know that I can access Access tables with ADO.NET (i.e. without automation).

My question is: Can I delete a report from an Access database file without using automation?


Notes:

  • In case it makes a difference: I'm stuck with legacy mdb databases at the moment, but if there's an accdb-only solution, I'd be curious about that as well.

  • Officially sanctioned solutions are preferred, but, if there are none, well-proven hacks (e.g. modifying MSysObjects in some way) or undocumented features are acceptable as well.

  • If you are wondering why I want to do this: The automation solution has a few drawbacks (indeterminism if multiple Access versions are installed; AutoExec is run if present; user interface messages might pop up; etc.) which I'd rather avoid.


Solution

  • I would say you can't. You have listed the options.

    Neither can the system tables be modified directly.

    But you could export a modified form which has had the option for opening the report disabled and hidden, thus effectively making the report inaccessible for the user.