标题: How to Fill a List Box with a List of Reports [打印本页] 作者: tmtony 时间: 2005-8-16 21:01 标题: How to Fill a List Box with a List of Reports 标题:How to Fill a List Box with a List of Reports .
It may be useful to present a user with a list of reports available to print from a specific form in a list box on that form. Here's a method and code that illustrates how to limit a list of reports presented on a form to a specific sub set of reports in your database:
1. Select a prefix to add to the name of the reports you want to display in on the specific form in the List Box. (In the example below, "cmgt_ " is the prefix used.)
2. Set the target list box to use a value list as its Row Source Type
3. Place code like the following to the "On Open" event of the form you are using; note that the code is version independent and will work in Access 97 and above: Sub Form_Open (Cancel As Integer)
On Error GoTo ErrHandler
Dim App As Object
Dim CurProject As Object
Dim CollReports As Object
Dim objRpt As Object
Dim strRptName As String, strReportList as String, i As Integer
If SysCmd(acSysCmdAccessVer) < 9 Then
i = 0
Set CurProject = CurrentDb
Set CollReports = CurProject.Containers("Reports")
Check out the "Other Reports" database in our free files area to see how extend this concept to load a list of reports into a command bar combo box and preview that report when the command bar combo is selected. 作者: chajiangliang 时间: 2005-8-17 06:09