Hi
I have a combobox on a reporting form which uses VBA in the On Load event to pull the values from the reports that I have in the database. Although the reports always show alphabetically from a - z in the navigation pane, they don't show in alphabetical order in the combobox. Is there any way I can update the code so that the list is always alphabetical from a - z so it's easier for users to find the report they're looking for?
Here's the code:
I have tried searching online for an answer but can't seem to find anything that I can make work so hopefully someone will be able to point me in the right direction.
I have a combobox on a reporting form which uses VBA in the On Load event to pull the values from the reports that I have in the database. Although the reports always show alphabetically from a - z in the navigation pane, they don't show in alphabetical order in the combobox. Is there any way I can update the code so that the list is always alphabetical from a - z so it's easier for users to find the report they're looking for?
Here's the code:
Code:
Private Sub Form_Load()
On Error GoTo ErrorHandler
'Pulls list of reports for report combo box and updates when new reports added
Dim NewValList As String
NewValList = ""
Dim Obj As AccessObject
For Each Obj In CurrentProject.AllReports
If Right(Obj.Name, 3) <> "Sub" Then
NewValList = NewValList + Chr(34) + Obj.Name + Chr(34) + ";"
End If
Next Obj
Me!ReportCombo.RowSourceType = "Value List"
Me!ReportCombo.RowSource = NewValList
Me!ReportCombo.value = Me!ReportCombo.ItemData(0)
Exit Sub
ErrorHandler:
Dim msg As String
msg = Err.Number & ":" & Err.Description
MsgBox msg
End Sub
I have tried searching online for an answer but can't seem to find anything that I can make work so hopefully someone will be able to point me in the right direction.