Hello. I have a listbox with label headers outside the listbox right above the columns. The objective is to 'click' the label header and sort the listbox by that column. What is actually happening is changing the rowsource. Below is the FUNCTION that I am trying to use. It all remains the same with the exception of the ORDER BY clause. If I take the sql below and place it in the label click event and remove the last line below and replace it with Me.lstLocationList.Rowsource = sql and specify 'BusinessUnit' as the ORDER BY the sorting works fine. The ORDER BY will change for each label. The db is sql server and the tables are linked.
Function SortLocationList(orderby As String)
Dim sql As String
sql = "SELECT LocationID, LocationName, LocationCity, Jurisdiction, Country, BIACode, LocationType, BusinessUnit, IsRemoveLocation " & _
"FROM dbo_vwLocation " & _
"WHERE IsRemoveLocation = 0 " & _
"ORDER BY orderby"
SortLocationList = sql
I have tried several ways to call this function in the label click event but either nothing occurs or the listbox is emptied out. No errors occur or warning messages.
What am I missing or not doing correctly?