Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 19th, 2007, 02:01 PM
Friend of Wrox
 
Join Date: Apr 2006
Posts: 159
Thanks: 0
Thanked 0 Times in 0 Posts
Default order elements of list box

Hi,

Just have a question. In my application I'm listing all the reports in a list box. This works fine. I'm populating the list with the next code that is set on the on open event of the form the list box is on:

dim Obj as AccessObject
For Each Obj in CurrentProject.AllReports
   Me.lstReports.AddItem Mid(Obj.Name,4)
Next

Like I said, this works fine, but when the form opens, the reports are not sorted alphabetically. Is it possible to become the same list in a sort order that is ascending? (I guess yes, but how can I get this?)

Thanks

 
Old April 24th, 2007, 07:04 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

That's a good one. I would be inclined to paste them to a table, and then base the list box on the table to get the sort function.

So:

DoCmd.SetWarnings False
DoCmd.OpenQuery "qryDELETETempTable"
DoCmd.SetWarnings True

'Open recordset (rs) on table

dim Obj as AccessObject
For Each Obj in CurrentProject.AllReports
   rs.AddNew
   rs("ListItem") = Mid(Obj.Name,4)
   rs.Update
Next

Me.lstReports.requery

This should work pretty fast.

Did that help?

mmcdonal
 
Old April 28th, 2007, 11:18 AM
Friend of Wrox
 
Join Date: Apr 2006
Posts: 159
Thanks: 0
Thanked 0 Times in 0 Posts
Default

This is working fine. Thanks very much






Similar Threads
Thread Thread Starter Forum Replies Last Post
display out of order html elements? chobo XSLT 2 April 1st, 2008 02:28 AM
multi-column list box values moved to 2nd list box sbmvr Access VBA 1 May 14th, 2007 01:58 PM
Check box and Order by vpatel1961 Classic ASP Basics 1 January 23rd, 2007 12:45 PM
Populate List Box by Combo Box Selection mmcdonal Access 2 June 15th, 2004 12:08 PM
Search using drop down list box and a text box tcasp Classic ASP Basics 1 July 31st, 2003 02:58 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.