alphabetical order of reports in a listbox

  • Thread starter imstuck via AccessMonster.com
  • Start date
I

imstuck via AccessMonster.com

i have this code on my list box:
This displays all the reports i have with "rpt" & "rpf" word at the beginning
of the report name.

Private Sub Form_Open(Cancel As Integer)
Dim objAO As AccessObject
Dim objCP As Object
Dim strValues As String
Set objCP = Application.CurrentProject
For Each objAO In objCP.AllReports
If Left(objAO.Name, 3) = "rpt" Or Left(objAO.Name, 3) = "rpf" Then
strValues = strValues & Mid(objAO.Name, 4) & ";" & Left(objAO.Name, 3)
& ";"
End If
Next objAO
lstReports.RowSourceType = "Value List"
lstReports.RowSource = strValues
End Sub


my problem is, i want to display the reports in alphabetical order. How can i
do that?
thanks
 
I

imstuck via AccessMonster.com

imstuck said:
i have this code on my list box:
This displays all the reports i have with "rpt" & "rpf" word at the beginning
of the report name.

Private Sub Form_Open(Cancel As Integer)
Dim objAO As AccessObject
Dim objCP As Object
Dim strValues As String
Set objCP = Application.CurrentProject
For Each objAO In objCP.AllReports
If Left(objAO.Name, 3) = "rpt" Or Left(objAO.Name, 3) = "rpf" Then
strValues = strValues & Mid(objAO.Name, 4) & ";" & Left(objAO.Name, 3)
& ";"
End If
Next objAO
lstReports.RowSourceType = "Value List"
lstReports.RowSource = strValues
End Sub

my problem is, i want to display the reports in alphabetical order. How can i
do that?
thanks


i also tried this:

SELECT [Name] FROM MsysObjects
WHERE (([Type] = -32764) AND ([Name] Not Like "~*") AND ([Name] Not Like
"MSys*"))
ORDER BY [Name];
 
D

Duane Hookom

Try:
SELECT Mid([Name],4) As RptName
FROM MsysObjects
WHERE [Type] = -32764 AND Right([Name],3) IN ("rpt","rpf")
ORDER BY Mid([Name],4);

--
Duane Hookom
Microsoft Access MVP


imstuck via AccessMonster.com said:
imstuck said:
i have this code on my list box:
This displays all the reports i have with "rpt" & "rpf" word at the beginning
of the report name.

Private Sub Form_Open(Cancel As Integer)
Dim objAO As AccessObject
Dim objCP As Object
Dim strValues As String
Set objCP = Application.CurrentProject
For Each objAO In objCP.AllReports
If Left(objAO.Name, 3) = "rpt" Or Left(objAO.Name, 3) = "rpf" Then
strValues = strValues & Mid(objAO.Name, 4) & ";" & Left(objAO.Name, 3)
& ";"
End If
Next objAO
lstReports.RowSourceType = "Value List"
lstReports.RowSource = strValues
End Sub

my problem is, i want to display the reports in alphabetical order. How can i
do that?
thanks


i also tried this:

SELECT [Name] FROM MsysObjects
WHERE (([Type] = -32764) AND ([Name] Not Like "~*") AND ([Name] Not Like
"MSys*"))
ORDER BY [Name];
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top