Report Names

  • Thread starter Thread starter Brian
  • Start date Start date
B

Brian

Does anyone know how to progamatically return the names of
all the reports in an Access database? Specifically, I
have designed a form that allows users to choose which
report to print from a drop-down box. Up until now, I
have manually populated that box with a Value List, but
every time I add a report, I must remember to go back and
change the Value List for that drop-down. I would think
that there could be some code on the OnOpen event for the
form that looks at all the report names and automatically
changes the Value List for the drop-down box.

Suggestions?
 
Hi Brian,

Set the Row Source of the combo box to this SQL statement:

SELECT MsysObjects.Name
FROM MsysObjects
WHERE (((Left$([Name],1))<>"~") AND ((MsysObjects.Type)=-32764))
ORDER BY MsysObjects.Name;

That should list all the reports in the database.

Jeff Conrad
Bend, Oregon
 
Actually, a simple query will do it:

SELECT msysobjects.Name FROM msysobjects WHERE msysobjects.Type=-32764

On my website (see sig below) are several small sample databases which
illustrate this with a number of variations. ChooseReportFromList,
ChooseReportFromList2, ChooseReportFromList3
 
Back
Top