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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Order a query in a listbox on several columns

Status
Not open for further replies.
Mar 27, 2002
168
NL
I build a query in the wizard (access2002)
I filled a listbox with the columns of the query
I also filled a combobox with the names of the columns, see below:
Public Sub VulsorteerLijst()
Dim intNumColumns As Integer, intI As Integer
Dim strSQL As String, frm As Form

Set frm = Forms!frmLogboekGewRec

intNumColumns = frm!lstLogboek.ColumnCount
strSQL = ""
For intI = 0 To intNumColumns
strSQL = strSQL & frm!lstLogboek.Column(intI, 0) & ";"
Next intI
frm!cboSort.RowSource = strSQL
End Sub

But now I want to do the following trick:
in the afterUpdate_event of the combobox I want to Order the columns ASC on the selected column. But I'm not using the recordsource property but only the listbox.requery
can u order in this way?
Thnx in advance,

gerard
 
I'm not sure if this is really what you are after, but I have just written an application that includes a pop-up form to display an address list in a listbox. At the top of each address element, i.e. street, town, etc., there is a command button that will sort the data in the listbox on the column selected. For example, to sort into town order the command button code contains:


Private Sub cmdTown_Click()
Dim strsql As String

strsql = "SELECT DISTINCTROW AddressID, Number,AddressLine1,AddressLine2,District,Town,County, Postcode "
strsql = strsql & "FROM tblAddress "
strsql = strsql & "ORDER BY Town"

Me.List0.RowSource = strsql
Me.List0.Requery

End Sub

Any help?


JR
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top