Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sorting a Column Access VB

Status
Not open for further replies.

MattSTech

Programmer
Joined
Apr 10, 2003
Messages
333
Location
US
Relatively simple question, could not find answer elsewhere.

How would I sort a column as I would by right clicking the column in Access, then selecting "Sort Ascending", programmatically in VB6?

I would simply like to sort the column after every update I execute.

Thanks for the help

Matt

 
Hello Matt,

In what context are you trying to do this? In table view, in a combobox or some other way?

Good Luck!

Have a great day!

j2consulting@yahoo.com
 
I have an interface to a database built in VB6. When I add the name "Smith, John" it is placed at the bottom of the list.

When I click the "add" button in my interface, I would like the record to be added, then the column resorted in alphabetical order before I close the connection.

The incoming data must be sorted before it is loaded into the interface or I would use the "Sorted" property of the list box it is contained in.

I am using ADODC.
Thanks again for the quick response!

Matt
 
Can you refresh or requery your underlying form data? Just a thought.

Good Luck!

Have a great day!

j2consulting@yahoo.com
 
At form load, the query reads the data from BOF to EOF into several List boxes. I have the main list box "Name" driving the index of the other list boxes. When I select a different "Name" the database isn't requeried, it simply moves the other listboxes to the appropriate index. Thus my problem with sorting the listbox.

I just assumed there would be a one liner out there like:

SORT tblNameData|NAME ,A to Z

where NAME is the column to sort by.
I know, I know, I dream

Thanks

Matt
 
Still looking for a solution...
 
If you can use a select statement, use order by clause to sort the col and take it to the recordset. If you are using a list, then create a generic sub that will fill the list, and then call the sub after each insert..
 
How are you accessing your DB?

In your SQL just change the Order.
Ex: SELECT * FROM Main ORDER BY Main.Field1;

This will sort your table for you then you can go from BoF to EoF. Hard to give you a good example on this as I really have no idea what your program is doing.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top