Results 1 to 2 of 2
  1. #1
    kagoodwin13 is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Feb 2012
    Posts
    181

    Combobox - Toggle sort between columns

    I am trying to develop a button (or combobox or option group) that would toggle the sort in a separate combobox that has two columns -- SKU, and Product Name. I would like to toggle between sort by SKU ascending (A-Z), or by Product Name ascending.



    Currently, I have SKU ascending as the default when the form loads. I am able to toggle to Product Name ascending once via a combobox. However, I am not able to toggle back again! I can toggle once, but not toggle continuously.

    Any help?

    Code:
    Private Sub Combo13_AfterUpdate()
    Dim strSQL As String
    Dim strSQLa As String
    
    strSQL = "SELECT qryData.SKU AS [Product SKU], qryData.ProdName AS [Product Name] " & _
            "FROM qryData"
    
    'SKU ascending
    Select Case Combo13.Value
    Case "SKU"
        strSQLa = strSQL & "ORDER BY qryData.SKU ASC;"
    'Product Name ascending
    Case "ProductName"
        strSQLa = strSQL & "ORDER BY qryData.ProdName ASC;"
    End Select
    
    Me.cboProdSelect.RowSourceType = "Table/Query"
    Me.cboProdSelect.RowSource = strSQLa
    
    End Sub

  2. #2
    kagoodwin13 is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Feb 2012
    Posts
    181
    I had a mismatch between the values in Combo13 (SKU,ProdName) and in the Case lines (SKU,ProductName). This now works. I'll leave it here in case others are wanting to do the same. Marked as solved.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 5
    Last Post: 08-14-2015, 02:53 PM
  2. Replies: 5
    Last Post: 06-14-2015, 07:56 PM
  3. Sort Columns in an excel worksheet and Pivot table
    By Jhail83 in forum Programming
    Replies: 3
    Last Post: 09-04-2013, 09:07 AM
  4. Query -- Sort two columns
    By snowboarder234 in forum Queries
    Replies: 2
    Last Post: 11-15-2012, 03:26 PM
  5. Report will order/sort 4 columns but not 5. Why?
    By TomHolden in forum Reports
    Replies: 6
    Last Post: 12-17-2011, 04:25 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums