I have this form which I want to be able sort by clicking on a command button.
For instance if the button is above the "stocks" field 9textbox) - clicking
on the command button right above it would sort it descending. --- clicking
on the command button above the field "Profits" -- it would be sort it
descending by the amount.
I can currently do this by clicking the sort button in the toolbar, but I
want to do this via vba cide.
JPierre
Carl Rapson - 13 Jul 2007 19:46 GMT
>I have this form which I want to be able sort by clicking on a command
>button.
[quoted text clipped - 10 lines]
>
> JPierre
What you would need to do is, in the button's Click event modify the form's
OrderBy property to include the proper sorting. Be sure to also set
OrderByOn to True when you do so. Look in Access help for OrderBy and
OrderByOn.
You could also accomplish this by changing the form's RecordSource property
directly, if you wished.
Carl Rapson
Marshall Barton - 13 Jul 2007 20:06 GMT
>I have this form which I want to be able sort by clicking on a command button.
>
>For instance if the button is above the "stocks" field 9textbox) - clicking
>on the command button right above it would sort it descending. --- clicking
>on the command button above the field "Profits" -- it would be sort it
>descending by the amount.
Use code in each button's Click event procedure:
Me.OrderBy = "[Stocks] DESC"
Me.OrderByOn = True

Signature
Marsh
MVP [MS Access]