Sandra Smith
asked on
Change sort order on a sub-form in VBA
I have a form that users copy/paste directly into. The source data comes from another application that spits out in Excel. The user then highligyhts the area needed and copies this directly into the sub-form (for various reasons, cannot upload). So, now the data is in the sub-form, but I need a way for the user to be able to sort via a command button by Branch Number either ascendig or descending. Since there is no query or an open event, I cannot use these so must resort to a button. I got as far as the OrderBy, but that does not work. I simply want the data on the sub-form sorted either direction when the user hits the sort button.
Private Sub cmdBranchSort_Click()
Me.sfmAMLItems.Form.OrderBy
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
DatabaseMX works but now that the data is in ascending, would I set the OrderByOn = False? Think I will go try that and see what happens.
ASKER
Works, used the toggle as I am cramped for space. As it toggles, the caption changes so the user knows which direction he is going.
Thank you.
Thank you.
Me.sfmAMLItems.Form.OrderB
You either need two buttons (Asc or Desc) ... or ... retain the previous state and toggle it. I would suggest two buttons.
mx