473,323 Members | 1,574 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,323 software developers and data experts.

Sort data in a listbox in alphabetical order

Hi

I have a listbox which is getting data from a access database and the listbox has names in it and im trying to put the names in alphabetical order.

Any help will be appreciated
Feb 6 '13 #1
8 12782
Seth Schrock
2,965 Expert 2GB
If the Row Source of your list box is a table, then you need to make a query based on that table. Make the query sort your names and then base your list box on the query.

If the Row Source is already based on a query, then just add the sorting to the query.

If the Row Source has SQL code in it (ie. SELECT * FROM...) then you just need to put an ORDER BY and then your field name at the end of it.
Feb 6 '13 #2
Sorry im still confused im quite new to this :(
Feb 6 '13 #3
Seth Schrock
2,965 Expert 2GB
I would be glad to help your confusion, but I'm not sure which part is confusing you. Perhaps reading How to ask good questions and then re-phrasing your question to follow these guidelines would help your question be clearer so that I can help your confusion.
Feb 6 '13 #4
Okay so at the moment in my listbox row source i have this
Expand|Select|Wrap|Line Numbers
  1. "SELECT tblMember.MemberNo, tblMember.Title, tblMember.Name, tblMember.Name FROM tblMember WHERE (((tblMember.Name) Like '*')) ORDER BY tblMember.Name"
When i go onto query view and press run the data shows as alphabetical order in the database. However on my program when i click to open the form and on "find" i click in the text box but all the names are still not in alphabetical order. So im not sure howcome , since ive managed to get all the names from the database into the list box.
Feb 6 '13 #5
Yes get in there its working thank you very much!!!!!!!!!!!!!
Feb 6 '13 #6
Seth Schrock
2,965 Expert 2GB
I'm not sure why it isn't alphabetizing in the list box if it is in the query, but I'll give it a try.

Try this:
Expand|Select|Wrap|Line Numbers
  1. SELECT MemberNo, Title, Name
  2. FROM tblMember
  3. ORDER BY Name
You don't need a WHERE clause since you are wanting all the names. You also have two Name fields, so I removed one. Give it a try and let me know what the results are.

Oh, by the way, what is the column count and the column width properties for your list box?
Feb 6 '13 #7
Seth Schrock
2,965 Expert 2GB
Good! I didn't see your "its working" post until I posted mine.
Feb 6 '13 #8
@ebrahim1
thanks dude it helped alot :)
Feb 26 '13 #9

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

Similar topics

1
by: Richy Rich | last post by:
Hi, This may seem like a really stupid question, but I cannot get the source files to appear in alphabetical order in the solution explorer. I've clicked on the A...Z icon, but they don't...
2
by: yenra | last post by:
..how can I insert entry in a linked list and arrange my entries according to the name in alphabetical order? I need to make a student record which contains the name, yr level and course of the...
1
by: MichaelFord85 | last post by:
I have built an MS access with student information, such as SSN, Local address, city, state, grade, etc. The SSN is the primary key for the student table - there is a second table but that isn't...
4
Cyberdyne
by: Cyberdyne | last post by:
In your All Programs Menu, some of your programs are in alphabetical order and others are not. This makes it very difficult to seek out a program that may be hidden in a maze of program folders and...
7
by: canteyn | last post by:
Here is my problem: Structure typedef struct { char lname; char fname; int age; double salary; } employee_t;
3
by: eagerlearner | last post by:
I have the following code, which does not sort the list in alphabetical order, how can I sort everything in alphabetical order ? Before that, I want to ask, when an insertion occur, does it compare...
1
by: HaifaCarina | last post by:
these are the loops i used: for (h = 0; h<name.length;h++) { highestOrder = Integer.valueOf(name.charAt(0)); highestName = name; for (int count...
2
by: pavanip | last post by:
Hi, I have a problem with binding data to dropdownlist from database in alphabetical order. My database contains some fields like All,Air,Airline,Books,Cars etc. There are 2 dropdown...
5
by: kylie991 | last post by:
I'm confused as to why this isnt working.. am i doing this right?? I have to create a function that does the following: - Insert a word to the linked list so that the list // ...
12
by: Nzsquall | last post by:
Hi, I am having trouble sorting a client contact lists by their surname. Every time when I press the "sort by surname button, it always appear alphabetical order by clients' first name, because I...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.