How do I change the record source of a list box.

F

Frank Martin

(Access2003)

I have a list box on a form to list & select a particular
customer invoice. This is sorted by Date descending.

Occasionally I want the info in the listbox sorted by
Customer ascending.

What is the simplest way to alter this sort order with the
press of a button.

Is it possible to put sorting bars at the top of the columns
in a list box?

Please help, Frank
 
F

fredg

(Access2003)

I have a list box on a form to list & select a particular
customer invoice. This is sorted by Date descending.

Occasionally I want the info in the listbox sorted by
Customer ascending.

What is the simplest way to alter this sort order with the
press of a button.

Is it possible to put sorting bars at the top of the columns
in a list box?

Please help, Frank

What is the List box Row Source?
A Query?
When do you want to change the sort?

Change the sort in the list box rowsource.
For example, code a command button click event:

If InStr([ListBoxName].RowSource,"Order By Customer Desc")>0 Then
Me.[ListBoxName].Rowsource = "Select TableName.Customer from TableName
Order by Customer Asc"
Else
Me.[ListBoxName].Rowsource = "Select TableName.Customer from TableName
Order by Customer Desc"
End If

This will toggle the list box sort between Desc and Asc.
 
F

Frank Martin

Thanks, FM

fredg said:
(Access2003)

I have a list box on a form to list & select a particular
customer invoice. This is sorted by Date descending.

Occasionally I want the info in the listbox sorted by
Customer ascending.

What is the simplest way to alter this sort order with
the
press of a button.

Is it possible to put sorting bars at the top of the
columns
in a list box?

Please help, Frank

What is the List box Row Source?
A Query?
When do you want to change the sort?

Change the sort in the list box rowsource.
For example, code a command button click event:

If InStr([ListBoxName].RowSource,"Order By Customer
Desc")>0 Then
Me.[ListBoxName].Rowsource = "Select TableName.Customer
from TableName
Order by Customer Asc"
Else
Me.[ListBoxName].Rowsource = "Select TableName.Customer
from TableName
Order by Customer Desc"
End If

This will toggle the list box sort between Desc and Asc.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top