VBA sort code DESCENDING

  • Thread starter Thread starter VWP1
  • Start date Start date
V

VWP1

I am using VBA code behind a form, to sort as follows:

Private Sub ob_org_Click()
Me.OrderBy = "org"
Me.OrderByOn = True
End Sub

where org is the fieldname in the table. It works great. No problem.

I need to click either the same button or another button to sort the other
way (DESC).
 
VWP1 said:
I am using VBA code behind a form, to sort as follows:

Private Sub ob_org_Click()
Me.OrderBy = "org"
Me.OrderByOn = True
End Sub

where org is the fieldname in the table. It works great. No problem.

I need to click either the same button or another button to sort the other
way (DESC).


Me.OrderBy = "org DESC"
 
VWP1 said:
I am using VBA code behind a form, to sort as follows:

Private Sub ob_org_Click()
Me.OrderBy = "org"
Me.OrderByOn = True
End Sub

where org is the fieldname in the table. It works great. No problem.

I need to click either the same button or another button to sort the other
way (DESC).


For another button:

Private Sub ob_org_desc_Click()
Me.OrderBy = "org DESC"
Me.OrderByOn = True
End Sub

For a single button:

Private Sub ob_org_Click()
If Me.OrderBy Like "*DESC" Then
Me.OrderBy = "org"
Else
Me.OrderBy = "org DESC"
End If
Me.OrderByOn = True
End Sub
 
Thank you very much!

Marshall Barton said:
For another button:

Private Sub ob_org_desc_Click()
Me.OrderBy = "org DESC"
Me.OrderByOn = True
End Sub

For a single button:

Private Sub ob_org_Click()
If Me.OrderBy Like "*DESC" Then
Me.OrderBy = "org"
Else
Me.OrderBy = "org DESC"
End If
Me.OrderByOn = True
End Sub
 
Back
Top