Link to home
Start Free TrialLog in
Avatar of Frank Freese
Frank FreeseFlag for United States of America

asked on

Not sorting Ascending

Folks,
In my Access 2016 form I have various fields that when you click on their label it will sort the table Descending. For example, if I clicked on the label Address for the Address control then then table is sorted Descending. What I haven't figured out is if I wanted to then click on the same label it would sort Ascending.

Private Sub Address_Label_Click()
        Me.OrderBy = "Address"
        If Me.OrderBy = "Address" Then
           Me.OrderBy = "Address DESC"
        Else
           Me.OrderBy = "Address"
        End If
End Sub

Open in new window

Avatar of Anders Ebro (Microsoft MVP)
Anders Ebro (Microsoft MVP)
Flag of Denmark image

You were close, you just need to remove the first line of your code:
Private Sub Address_Label_Click()
        If Me.OrderBy = "Address" Then
           Me.OrderBy = "Address DESC"
        Else
           Me.OrderBy = "Address"
        End If
End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of John Tsioumpris
John Tsioumpris
Flag of Greece image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Frank Freese

ASKER

Thanks to the two of you. John your code worded perfectly!