Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing the sort of a form with a command button 1

Status
Not open for further replies.

rew2009

Technical User
Apr 21, 2009
114
US
I have an Access form that is controled by a query "CientQRY" that has a record source that is sorted or ordered on a field "ClientName". I would like to be able to change that sort to another field "City" in the same query with a command button within the form. How do I do it? Thanks
 
In the Click event procedure of your button:
Code:
Me.OrderByOn = False
Me.OrderBy = "City"
Me.OrderByOn = True

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks PHV, that worked. But I find I now need to have it stay on the record that was selected before the change of ordering. I presume I need something like: if srtA=ID where ID is for the current record then after the change of ordering have "goto record srtA" But I need the correct language and syntax etc. Also, How do I make the ordering "DESC"?
 
I figured out the "DESC" part of my question. I'll start a new thread on the staying on the record part after reordering. Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top