Hi,
I have a list box based on a quite a complex query. I would like give the user the option to dynamically sort the list box.
How can I refer to my listbox's SQL rowsource and add a sort order using VB?
i.e.
I am aware of how I could do this if my SQL was in VB i.e.:
....but my query is far more complex than this and I dont want to have to keep calling the code each time I need to requery my form.
Thanks
BF
I have a list box based on a quite a complex query. I would like give the user the option to dynamically sort the list box.
How can I refer to my listbox's SQL rowsource and add a sort order using VB?
i.e.
Code:
Private Sub CmdButtonSortByName_Click
Dim strSQL as String
strSQL = me.listbox.rowsource & "ORDER BY FieldName;"
me.listbox.rowsource = strSQL
I am aware of how I could do this if my SQL was in VB i.e.:
Code:
Dim strSQL as String
Dim strSortOrder as String
Dim optSort as Integer
Select Case optSort.Value
Case 1
strSortOrder = "ORDER BY LastName;"
Case 2
strSortOrder = "ORDER BY FirstName;"
End Select
strSQL = "SELECT FirstName, LastName FROM TblName " & strSortOrder
Me.ListBox.Rowsource = strSQL
....but my query is far more complex than this and I dont want to have to keep calling the code each time I need to requery my form.
Thanks
BF