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.