VBA sort code DESCENDING

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).
 
D

Dirk Goldgar

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"
 
M

Marshall Barton

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
 
V

VWP1

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top