|
|
Question : Sort records ascending / descending using same command button
|
|
Dear experts, I would like to sort records ascending and descending in a continuous form using a single command button. I.e. click once to sort ascending and click again to sort descending. Sounds easy, but then I've said that before! Using Access 97. Help appreciated.
|
Answer : Sort records ascending / descending using same command button
|
|
You can do something like this in your command button: If IsNull(Me.OrderBy) Or Me.OrderBy="[MyField] DESC" Then Me.OrderBy = "[MyField]" Else Me.OrderBy = "[MyField] DESC" End If Me.OrderByOn = True
The above code switches the ordering from ascending to descending depending on the current sort order (DESC orders the field descending). MyField is the name of the field that you want to order on.
HTH!
|
|
|
|