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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Listbox of reports in a form to preview and/or print

Status
Not open for further replies.

hermitsrest

Technical User
Feb 23, 2001
1
0
0
GB
I am trying to do a listbox of available reports in Access 97. I found instructions on how to do it in Access 2, but I cannot seem to get it to work.

Any ideas?

Thankyou in advance
Paula
 
the easiest way is to run a query on the system table MSysObjects the type for reports is -32764.
to view system tables select tools, options and put a check in system objects

HTH
 
Try using this:

Public Function ReportsList(strCriteria As String)
Dim db As DATABASE
Dim docLoop As Document
Dim prpLoop As Property
Dim strReports As String
Set db = CurrentDb
strReports = """"

With db.Containers!Reports

' Run through reports documents
For Each docLoop In .Documents
If docLoop.Name Like "*" & strCriteria & "*" Then
strReports = strReports & docLoop.Name & Chr(34) & ";" & Chr(34) & docLoop.Properties!DESCRIPTION & Chr(34) & ";" & Chr(34)
End If
Next docLoop
db.Close
End With
ReportsList = Left(strReports, Len(strReports) - 2)
End Function

It will return a comma delimited list of all reports in your database. You can then use it as the rowsource of a listbox. It returns two columns for each report, the report name and the report description. While you don't HAVE to have a report description, it helps if you add it for each report, as this will show it. To add a description, right-click the report, then click "properties". You will see a description field.

Tim Gill
Gill Consulting
 
Opps, I made a mistake. You HAVE to have a description for each report, otherwise it will generate an error.

I use it like this:

me.lstReports.rowsource = reportlist("*")

The asterisk tells it to return all reports. You can also pass any string for it to look for. Say you have 5 reports about sales. If they all contain the string "sales" in their names, the do this to return them:

me.lstReports.rowsource = reportlist("sales")

Hope that helps. Tim Gill
Gill Consulting
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top