473,513 Members | 2,359 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Sorting Multi-Column List Box - Access 2003

11 New Member
I have a Multi-Column List Box named List10 that is populated via a query (qry_OptimizeIt3). I’m looking to create three Buttons, one above each column that will re-sort the list in ascending order based on the specific column. For example:

FIRSTNAME LASTNAME AGE
John Doe 24
Bill Jones 43
Judy Smith 21
Sally Johnson 38

I thought I could have each button change the RowSource order of the List Box using simple VBA code; something like:

Private Sub SortOrder1_Click()
List10.RowSource = CurrentDb.QueryDefs(qry_OptimizeIt3a).SQL & " ORDER BY " & strFIRSTNAME
End Sub

However, this gives me the error message “Item not found in this collection” and points to the line List10.RowSource = CurrentDb.QueryDefs(qry_OptimizeIt3a).SQL & " ORDER BY " & strFIRSTNAME

I appreciate any input you can provide.


Krazy (Bill) Kasper
Aug 26 '08 #1
2 6025
ADezii
8,834 Recognized Expert Expert
Assuming your Table Name is Employees, and your Command Button Names are cmdFirstName, cmdLastName, and cmdAge:
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdFirstName_Click()
  2. Me![List10].RowSource = "Select Employees.FirstName, Employees.LastName, Employees.Age " & _
  3.                         "FROM Employees Order by Employees.FirstName;"
  4. End Sub
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdLastName_Click()
  2. Me![List10].RowSource = "Select Employees.FirstName, Employees.LastName, Employees.Age " & _
  3.                         "FROM Employees Order by Employees.LastName;"
  4. End Sub
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdAge_Click()
  2. Me![List10].RowSource = "Select Employees.FirstName, Employees.LastName, Employees.Age " & _
  3.                         "FROM Employees Order by Employees.Age;"
  4. End Sub
Aug 27 '08 #2
nico5038
3,080 Recognized Expert Specialist
An easy alternative might be to use a datasheet subform as that can be sorted with the right-click options and the A>Z and Z>A buttons.
Moreover the user can also filter such a datasheet with the right click and re-arrange the columns to sort on multiple fields....

Nic;o)
Aug 27 '08 #3

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

Similar topics

3
2965
by: Paul Kirby | last post by:
Hello All I am trying to update me code to use arrays to store a group of information and I have come up with a problem sorting the multiple array :( Array trying to sort: (7 arrays put into...
11
2074
by: Alan Searle | last post by:
I have been trying to get an array to sort on a particular column and have been having problems with my main key ... array_multisort($dirlist, SORT_DESC, SORT_STRING); This function takes an...
5
1794
by: Eclectic | last post by:
Hey all, I have been using usort to sort my multi dimensional arrays ... function cmp($a, $b){ if($a == $b){ return 0; } return ($a < $b) ? -1 : 1; }
0
1349
by: MightyKitten | last post by:
Is there any quick way to data put in a multi-line textfield? The data are numbers (each number on a seperate line, raning from 1 to about 1.000.000) All of them are integers. The result should be...
9
3594
by: p0wer | last post by:
Let's suppose I have this sample document: <root> <entry id="1" <date>2003-08-03</date> <param_1>5</param_1> <param_2>10</param_2> </entry> <entry id="2"> ...
7
3024
by: Karin Jensen | last post by:
Hi I am running a PHP program that connects to an Access 2000 database via ODBC: $results = odbc_exec($connection_id, $sql_select); Is it possible to sort the contents of $results? I wish to...
1
8968
by: Christopher Miles | last post by:
Hello, I am trying to sort this array by the time field , and have all the other fields move accordingly to match .. Group_Array(0) - name Group_Array(1) - severity Group_Array(2) - Time...
9
2585
by: Dylan Parry | last post by:
Hi folks, I have a database that contains records with IDs like "H1, H2, H3, ..., Hn" and these refer to local government policy numbers. For example, H1 might be "Housing Policy 1" and so on....
4
1512
by: comparc | last post by:
Suggest me some magic way so that by the time I finish reading all the elements of the string into main memory for computing, the list is already sorted.
5
5254
by: JC | last post by:
Hi all, I have scoured the internet for articles on sorting multi-dimensional arrays of generic types e.g. T using the IComparer<Tinterface and have run into a real roadblack. There does not...
0
7265
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
7171
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7545
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...
1
7111
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
7539
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...
1
5095
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3240
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3228
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1605
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.