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

sort listbox with criteria from cmbbox

Status
Not open for further replies.

CTOROCK

Programmer
May 14, 2002
289
US
I have a combo box with values I type in. I also have a list box that requeries with some updates. I would like the listbox to display the table sorting by the value that was selected in the combo box. I try this:


Private Sub CmbSort_AfterUpdate()
Dim strSFSQL As String
Dim strLBSQL As String

strSFSQL = "SELECT EngLog.ID AS [Log ID], EngLog.Category, EngLog.[Project Name], EngLog.[Sales Order 1] AS [SO 1], EngLog.Description, EngLog.[Assigned To], EngLog.[Date In],EngLog.[ECN No],EngLog.[ECR No],EngLog.[Actual Date Out],EngLog.[Order Size] " & _
"FROM EngLog"

'strLBSQL = strSFSQL & " ORDER BY EngLog.category;"
strLBSQL = strSFSQL & " ORDER BY EngLog.[cmbsort.value];"

Me!LstSearchItems.RowSource = strLBSQL
Me.LstSearchItems.Requery
Me.txtRecordCount = LstSearchItems.ListCount - 1
End Sub

Does anyone know why it won't take the cmbsort.value? Thanks in advance for anyone's time!

It's been a while since i've done this, thanks!

"The greatest risk, is not taking one."
 
Well I did this: If CmbSort.Value = "category" Then
strLBSQL = strSFSQL & " ORDER BY EngLog.category;"
ElseIf CmbSort.Value = "Log ID" Then
strLBSQL = strSFSQL & " ORDER BY EngLog.Id;"
ElseIf CmbSort.Value = "Project Name" Then
strLBSQL = strSFSQL & " ORDER BY EngLog.[Project Name];"




End If
'StrSort = CmbSort.Value
'strLBSQL = strSFSQL & " ORDER BY = " & StrSort

Me!LstSearchItems.RowSource = strLBSQL
Me.LstSearchItems.Requery
Me.txtRecordCount = LstSearchItems.ListCount - 1

But i know it's not efficient

"The greatest risk, is not taking one."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top