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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Arranging Records

Status
Not open for further replies.

LeighW

Programmer
Jun 6, 2001
45
GB
I have a form with a subform, the subform is a continuous form with lots of records in. I want to be able to click on the heading of each column to sort the records in assending order by that column, I don't want to view the data in datasheet view as I have many buttons etc in the subform! But I am not sure how to do it!

Can anyone please help...

Thanks

Leigh
 
Instead of using Labels for your column headings, use unbound textboxes. Set the default value of the text box to the heading you want displayed. Lock the text boxes and remove the tab stop. Now the text box will act fairly similar to the label you had there originally with one exception: you can now set a procedure on the OnClick event for the text box. In the OnClick event you want the following code:
Code:
Me.OrderBy = "[FieldName]" 
Me.OrderByOn = True

This will cause the data to be sorted in ascending order by the field [FieldName]. If you want it to be descending order then use:
Code:
Me.OrderBy = "[FieldName] Desc"

Let me know if that doesn't solve your problem Jonathan
________________________________________
It is not fair to ask of others what you are unwilling to do yourself.
-Eleanor Roosevelt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top