Toggle Combobox Sort Order

  • Thread starter Thread starter Valerie
  • Start date Start date
V

Valerie

I have a combobox name Account_Num in a continuous subform. The combobox is
based upon a very simple query called AcctDescQry. The combobox pulls two
fields
1)AcctNum
2)AcctDesc

I would like to toggle the sort order with a toggle button between AcctNum
ascending and AcctDesc ascending. I am a novice at Access. Any help would
be appreciated.

Thank you
Valerie
 
I have a combobox name Account_Num in a continuous subform. The combobox is
based upon a very simple query called AcctDescQry. The combobox pulls two
fields
1)AcctNum
2)AcctDesc

I would like to toggle the sort order with a toggle button between AcctNum
ascending and AcctDesc ascending. I am a novice at Access. Any help would
be appreciated.

Thank you
Valerie


Make sure the ComboBox Rowsource is a query.
Add, or remove, Desc to the Order By clause.

Rather than an extra button to toggle the sort, why not just
Double-click that combo box.
Code the ComboBox double-click event:

If Me!ComboName.Rowsource = "Select ...etc. Order By
YourTable.FieldName;" Then
Me!ComboName.Rowsource = "Select ...etc. Order By
YourTable.FieldName Desc;"
Else
Me!ComboName.Rowsource = "Select ...etc. Order By
YourTable.FieldName;"
End If
Me!ComboName.Requery

If you do wish a separate button, the code is the same as above.
 
Thanks, I was able to get it working.

Valerie
fredg said:
Make sure the ComboBox Rowsource is a query.
Add, or remove, Desc to the Order By clause.

Rather than an extra button to toggle the sort, why not just
Double-click that combo box.
Code the ComboBox double-click event:

If Me!ComboName.Rowsource = "Select ...etc. Order By
YourTable.FieldName;" Then
Me!ComboName.Rowsource = "Select ...etc. Order By
YourTable.FieldName Desc;"
Else
Me!ComboName.Rowsource = "Select ...etc. Order By
YourTable.FieldName;"
End If
Me!ComboName.Requery

If you do wish a separate button, the code is the same as above.
 
Back
Top