Dynamic freport list not functioning
I have created a form call frmlistreports, which displays a list of available "global" reports. This list is dynamic, each time a user creates and saves a new report, it is added to the available list (see code below). I have been able to exclude [hide certain reports (those that begin with X_ and run from a specific screen or individual's record) to alleviate confusion, etc.
I have two problems, which have eluded me.
1) I would like to have the reports displayed in alphabetical order when the form is opened or gets the focus back. I have tried everything I can think of and nothing works.
2) I would like to expand my If statement to allow additional exclusionary criteria (i.e. a series of "Maintenance" reports [Starting with Maint_] ) would only be seen from a Maintenance form and all others would be hidden, while the Maintenance reports would not show on the main form. I am really stumped here, have tried many permeations of If Then Else, nothing works for me.
â Code to create dynamic report list
Private Sub Form_Load()
Dim objao As AccessObject
Dim objcp As Object
Dim strValues As String
Set objcp = Application.CurrentProject
ListReports.RowSourceType = "Value List"
â Code to exclude reports starting with X_ from the dynamic report list
For Each objao In objcp.AllReports
If Left(objao.Name, 2) <> "X_" Then
strValues = strValues & objao.Name & ";"
ListReports.RowSource = strValues