Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old April 19th, 2007, 02:01 PM
Friend of Wrox
 
Join Date: Apr 2006
Location: Ternat, , Belgium.
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

Reply With Quote
  #2 (permalink)  
Old April 24th, 2007, 07:04 AM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
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
Reply With Quote
  #3 (permalink)  
Old April 28th, 2007, 11:18 AM
Friend of Wrox
 
Join Date: Apr 2006
Location: Ternat, , Belgium.
Posts: 159
Thanks: 0
Thanked 0 Times in 0 Posts
Default

This is working fine. Thanks very much

Reply With Quote
Reply


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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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 11:45 AM
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



All times are GMT -4. The time now is 02:07 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.