Results 1 to 2 of 2
Thread: delete Report in Code (XP DAO)
2007-02-18, 03:12 #1
- Join Date
- Aug 2002
- Brisbane, Queensland, Australia
- Thanked 1 Time in 1 Post
delete Report in Code (XP DAO)
I'm trying to delete a report using code and I tried - db1.AllReports(strReportName).Delete but I gather this is not available until 2003.
What should I be using? Do I need to use the docmd.deleteobject? if so how do you specify the database that contains the object?
2007-02-18, 10:04 #2
- Join Date
- Mar 2002
- Thanked 28 Times in 28 Posts
Re: delete Report in Code (XP DAO)
AllReports is available in Access 20002 (XP), but it is an Access collection, not a DAO collection, so you cannot use db1.AllProjects where db1 is a DAO database object. Moreover, you cannot use AllReports to delete a report.
In the current database, you can use DoCmd.DeleteObject to delete a table.
If you want to delete a report in another database, you must use Automation to start another instance of Access, open the database in it using OpenCurrentDatabase, then use DoCmd.DeleteObject to delete the report:
Dim app As New Access.Application
app.DoCmd.DeleteObject acReport, "NameOfReport"
Set app = Nothing