Results 1 to 7 of 7
  1. #1
    RobJ is offline Novice
    Windows 7 32bit Access 2003
    Join Date
    Oct 2020
    Posts
    4

    Delete a report in an external Access database

    I have a database that has been distributed to users. I have a need to replace one of the reports in the distributed database (small bug fix). I would like to send users a small database containing code to delete the old report in their database and replace it with the new report. I have been able to create the code to export the new report but not to first delete the old report.

    I have tried using this code:
    Code:
    Dim obj As AccessObject, dbs As Object
    Set dbs = Application.CurrentProject
    For Each obj In dbs.AllReports
        If obj.Name = "Report1" Then
            DoCmd.DeleteObject acReport, obj.Name
        End If
    Next obj
    This works perfectly well if dbs is the current database but if dbs is set to an external Access database I get an error message at the line
    Code:
     For Each obj In dbs.AllReports
    .



    Any help appreciated.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    This is not a split db?

    I can't find any reference with an example to accomplish this.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    RobJ is offline Novice
    Windows 7 32bit Access 2003
    Join Date
    Oct 2020
    Posts
    4
    No, not a split database. I want to be able to give users a program to run that will delete the old version of their report and copy a new version. I have created a small database with an Autoexec that will run the code to 1)
    Delete the old report and 2) copy the new report to their existing database. I can get step 2) to work but not step 1). The code I tried will work but only on the current project, not on an external project.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    I understand what you want and cannot find code that will delete a report in another db.

    Possibly might have to somehow copy a procedure into users db (maybe Docmd.TransferDatabase). That procedure would have the code to delete report and import new. None of this is anything I've ever tried. However, I do know how to call a procedure in another db.

    Are these distributed copies intended to be single-user? Even so, modifying interface would be much simpler if db was split.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    RobJ is offline Novice
    Windows 7 32bit Access 2003
    Join Date
    Oct 2020
    Posts
    4
    Thanks for you help. I misunderstood about the split db. The distributed app is a split db (front and back-end). I can simply provide an updated front-end db but thought it might be easier to just replace the report. I too could not find a method of achieving this but thanks for your time. Interestingly enough, the method I have tried does work if the object is a table.

  6. #6
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,977
    Whenever you want to modify or replace an object or module code in the FE of a split DB, you should always do so by distributing a new version of the FE.
    You can also run code from the new FE to modify the design of tables in the BE if necessary. That may be the code you were referring to earlier
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  7. #7
    RobJ is offline Novice
    Windows 7 32bit Access 2003
    Join Date
    Oct 2020
    Posts
    4

    Sound advice

    Quote Originally Posted by isladogs View Post
    Whenever you want to modify or replace an object or module code in the FE of a split DB, you should always do so by distributing a new version of the FE.
    You can also run code from the new FE to modify the design of tables in the BE if necessary. That may be the code you were referring to earlier
    Thanks isladogs. You are right, it does make sense to distribute a full, new version. That way you know it works. I'll take your advice.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 01-23-2015, 09:46 AM
  2. Replies: 2
    Last Post: 09-05-2014, 11:06 AM
  3. Replies: 1
    Last Post: 05-29-2013, 03:08 PM
  4. Delete in external database
    By theosgood in forum Programming
    Replies: 3
    Last Post: 10-06-2012, 01:27 PM
  5. Replies: 9
    Last Post: 10-05-2012, 06:15 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums