Sorting Records from ComboBox

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • aquanova
    New Member
    • Apr 2006
    • 1

    Sorting Records from ComboBox

    I'm working on Microsoft Access. I have a form which views the record of one table. Inside the form, there are several columns. Now I want to sort the records with using combobox. Eg. if the value of the combobox is "Date" then the record is automatically sorted by date itself, if "Name" if chosen then the form will be sorted based on the name...

    I'm new to VBA but I've done several SQL...
    Thank you...
    Last edited by aquanova; Apr 5 '06, 06:39 AM.
  • CaptainD
    New Member
    • Mar 2006
    • 135

    #2
    Is the form bound or unbound to the database?

    If it's unbound, you can set up your query where the order by clause is set by the combobox value.

    Select case combobox.text
    Case "Date"
    sOrderBy = "Order by [Date] ASC"
    Case "Last Name"
    sOrderBy = "Order by [LName] ASC"
    End Select

    sSelectString = sSelectString & sOrderBy

    Comment

    Working...