Results 1 to 2 of 2
  1. #1
    3 Star Lounger
    Join Date
    Aug 2002
    Location
    Brisbane, Queensland, Australia
    Posts
    387
    Thanks
    0
    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?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 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.OpenCurrentDatabase ("PathAndNameOfDatabase.mdb")
    app.DoCmd.DeleteObject acReport, "NameOfReport"
    app.Quit
    Set app = Nothing

Posting Permissions

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