Report Selection List from a button

C

cindyn

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?
 
D

Dirk Goldgar

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.
 
B

BIGRED56

Hi i have a question about this code..
The row source Select [name] would name = my report name and also
wouls MsysObjects = what is that and what is its value

thanks
 
A

Allen Browne

Try it.

Just as it is.

After you paste the SQL string in, view the query in design view if it
helps.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

BIGRED56 said:
Hi i have a question about this code..
The row source Select [name] would name = my report name and also
wouls MsysObjects = what is that and what is its value

thanks

Allen Browne said:
Two methods are explained in this article:
List Box of Available Reports
at:
http://members.iinet.net.au/~allenbrowne/ser-19.html
The first is much simpler, as it just uses a query.
 
Top