Fill a Combo Box with a List of Reports
This piece of code shows you how to fill a
combo box with a list of reports within the current database.
Create a form and put an unbound combobox on the from and call
it ReportList. Then put the following code in the form open event.
Private Sub Form_Open(Cancel As Integer)
Dim Dbs As Database
Dim Rpc As Container
Dim Rpt As Document
Set Dbs = CurrentDb
Set Rpc = Dbs.Containers!Reports
For Each Rpt In Rpc.Documents
ReportList.RowSource = ReportList.RowSource & Rpt.Name & ";"
Next
ReportList.Requery
Set Dbs = Nothing
Set Rpc = Nothing
Set Rpt = Nothing
End Sub |
After the form loads you'll have a combobox
with a list of the reports available. Once a user has selected a report you
could have a button which opens the report or prints it maybe. To find out the
report name just use Me.[ReportList].Value
Alternatively if you want to be a little smarter. Just put a
listbox on a form and set it's rowsource to :-
| SELECT Name FROM msysobjects WHERE (((msysobjects.Type)=-32764)); |
|