cindyn said:
I would like to create a button with a macro in it that will when
clicked open a list of all the current reports. Then the user could
select a report from the report list and that report would then open.
Does anyone know how to do this?
It's quite possible to build a query that returns a list of all the
report objects in the database, but I find it more useful to have a
table of reports, and use that (or a query of it) as the row source of a
list box. That way, my table can leave out subreports, can include a
descriptive name for each report so the user doesn't have to see the
actual object names, and can have a list-sequence field to control what
the order in which the reports appear in the list box.
Suppose you have such a table, tblReports, with fields ReportName,
ReportDescName, and ListSequence. Then you could create a popup form
with a list box, lstReports, with these properties:
RowSource: SELECT ReportName, ReportDescName
FROM tblReports ORDER BY ListSequence;
ColumnCount: 2
BoundColumn: 1
Width: 2"
ColumnWidths: 0"; 2"
Multiselect: None
The popup form would also have a command button, cmdOpenReport, with
this event procedure for its Click event:
'----- start of code -----
Private Sub cmdOpenReport_Click()
With Me!lstReports
If IsNull(.Value) Then
MsgBox "Pick a report first!"
Else
DoCmd.OpenReport .Value, acViewPreview
End If
End With
End Sub
'----- end of code -----
So any time you want to present the list of reports for opening, you
just open this form.