A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Setting Up & Running Reports
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

alphabetical order of reports in a listbox



 
 
Thread Tools Display Modes
  #1  
Old September 14th, 2009, 06:57 AM posted to microsoft.public.access.reports
imstuck via AccessMonster.com
external usenet poster
 
Posts: 2
Default alphabetical order of reports in a listbox

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

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ports/200909/1

  #2  
Old September 14th, 2009, 07:00 AM posted to microsoft.public.access.reports
imstuck via AccessMonster.com
external usenet poster
 
Posts: 2
Default alphabetical order of reports in a listbox

imstuck wrote:
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];

--
Message posted via http://www.accessmonster.com

  #3  
Old September 14th, 2009, 01:40 PM posted to microsoft.public.access.reports
Duane Hookom
external usenet poster
 
Posts: 7,177
Default alphabetical order of reports in a listbox

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" wrote:

imstuck wrote:
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];

--
Message posted via http://www.accessmonster.com


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 09:17 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.