473,396 Members | 1,827 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Listbox - Sorting in order of selection

I've created a listbox on a form to display a list of fields to be used to sort on a report. When users select from the listbox it sorts them in a number order. Is it possible to have it sort in order of which users select? Please help....

Here's my code:

Expand|Select|Wrap|Line Numbers
  1. Dim strsql As String
  2. Dim strYourSQLSelectFromStatement As String
  3. Dim strSQLWhere As String
  4. Dim varItem As Variant
  5. Dim strListLoanValues As String
  6.  
  7.     strListLoanValues = Forms!frmreport!List7.Column(0, varItem)
  8.  
  9.       If (Forms!frmreport!List7.ItemsSelected.Count = 0) Then Exit Function
  10.  
  11.       strYourSQLSelectFromStatement = ""
  12.  
  13.       strSQLWhere = vbNullString
  14.  
  15.     For Each varItem In Forms!frmreport!List7.ItemsSelected
  16.  
  17.     strListLoanValues = Forms!frmreport!List7.Column(0, varItem) & ", "
  18.     strSQLWhere = strSQLWhere & strListLoanValues
  19.  
  20. Next varItem
  21.  
  22. strSQLWhere = Left(strSQLWhere, Len(strSQLWhere) - 2)  'Get rid of last comma
Jun 1 '07 #1
1 2229
NeoPa
32,556 Expert Mod 16PB
When you open the report you can pass a list of the fields you want to sort by in the OpenArgs parameter.
In the report's Open event procedure, you can use this list to set up the two properties SortBy & SortByOn.
Good luck.
Jun 2 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Marri Suliez | last post by:
Has anyone found some documentation on how to properly subclass a ListBox control and provide custom sorting (when the list items come from a DataSource)? The only way I can figure out how to do...
8
by: Bill | last post by:
I'm trying to create a wizardlike interface using a couple listboxes. I know you've seen it before. You double click on an item in one listbox and it "moves" it to the other. I used to approach...
3
by: Mike Top | last post by:
I want a listbox to position to a letter provided by the user. Normally, when the user keys a letter, the listbox positions automatically to the first entry starting with that letter in the first...
10
by: Adam Clauss | last post by:
I have a page containing a list box. This list may contain duplicate items - in which the ORDER is important. ex: a b b a is significant as compared to: b
2
by: Joe Fallon | last post by:
I have 2 listboxes on a Web Form. As I move an item from 1 to the other it shows up at the end of the list. How can I sort the list that just got the new item added to it so it is in alphabetical...
1
by: valen1260 | last post by:
I'd like to have a multicolumn listbox, with one column being a list of items and the other being a list of checkbuttons. The user could check his "favorites" and then shorten the list to show...
5
by: JJ | last post by:
I want to have two lists (may have to be listboxes) on a page that are populated from a database. I then need to be able to click on an entry in one box and add it to the other, _preferably_...
7
imrosie
by: imrosie | last post by:
Hellol, I'm again in need of your help with my Order processing system.. My Order form is based on (query) of Customer and Order tables (includes a subform for the product data)...has a listbox...
5
by: jrod11 | last post by:
hi, I found a jquery html table sorting code i have implemented. I am trying to figure out how to edit how many colums there are, but every time i remove code that I think controls how many colums...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.