I have the following extract of code
I would like to use the code for combo box's as well. I could simply create a new sub in which I replace "ctlList As Listbox" with "ctlCombo As ComboBox", but this does not make sense. How can I modify the code so that I can call it from either a list box or a combo box?
I currently call the sub like this
Thanks in advance
Code:
Public Sub SortColumn(ctlList As Listbox, strField As String, strOrder As String, Optional strForceSortOrder As String)
Dim strSQL As String
Dim strSorted As String
Dim intInString As Long
Dim strSortOrder As String
dim strSQL as String
intInString = InStr(1, ctlList.RowSource, "Order By")
strSQL = ""
If intInString > 0 Then
strSQL = Left(ctlList.RowSource, intInString - 1)
Else
strSQL = ctlList.RowSource
End If
ctlList.RowSource = strSorted
ctlList.Requery
End Sub
I would like to use the code for combo box's as well. I could simply create a new sub in which I replace "ctlList As Listbox" with "ctlCombo As ComboBox", but this does not make sense. How can I modify the code so that I can call it from either a list box or a combo box?
I currently call the sub like this
Code:
SortColumn Me.lstCustomer, "Area", Me.cmdSortArea.Caption, ""