Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Deleting a report in VBA

Status
Not open for further replies.

RizMan

Programmer
Jun 13, 2003
20
FR
Ok, here's the situation
In my DB I am generating Reports dynamically depending on which fields the user choses to see in the report. Once the report is created the user can chose to save to Report in the DB.

If the user wants to see the report againg, he can view the saved reports in a new form which contains a listbox which in turn contains the names of all the reports.
The Listbox Rowsource Property is set in the From_Load Event

Private Sub Form_Load()
Dim obj As Object
Set obj = CurrentProject.AllReports
For Each aob In obj
If aob.name <> &quot;rptTemplate&quot; Then
strTemp = aob.name
strList = strList & strTemp & &quot;; &quot;
End If
Next
lstReports.RowSource = strList
End Sub

Now what I want is allow the user to delete the Report selected in the list. He would click a button: Delete Report or whatever.
Hoewever, I can't find any method of deleting a once saved report from the AllReports collection.

I need this because the user doesn't have access to the Database window and I can't be bothered to delete be asked to delete a report everytime the user decides that he doesn't want it.

Thanks in advance
 
Forgot to mention: Don't mind the if statement

if aob.name <> &quot;rptTemplate&quot; Then
...

rptTemplate is the template I use to generate the reports. So that one is very critical and shouldn't be seen by the user.
 
I found the solution. It was to obvious to see

docmd.DeleteObject acReport, [ReportName]

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top