Subform Sort Button

megamef

Registered User.
Local time
Today, 22:51
Joined
Apr 18, 2013
Messages
161
Hi All,

I'm displaying records in a subform that is in the datasheet format.

I would like a sort button on my main form so that I can click a column header, press this button and it can sort the datasheet ascending.

How can this be done?
 
Not sure if you can click the Column in the SubForm and then use the button to Sort.. But what you can do (my way ;)) would be to create an Unbound ComboBox, populate it with the headers of the RecordSource of the SubForm then select one and the use OrderBy..

You can wait for others for their opinion.. I am sure there should be a better way too..
 
Thanks Paul.

As I always do, I've asked the question too quickly as I've been playing and think I've found a solution.

Code:
 Dim HeaderName As String

HeaderName = Me!subform.Form.ActiveControl.Name


Me.OrderByOn = True
Me!subform.Form.OrderBy = HeaderName
Me.Refresh

Mind you there are still a few problems with this, as I need to be in the field itself for the sort to work and can't just click on the column headers in the datasheet.

Also I can't work out how to sort descending (should be easy?) .

Thanks
 
Why not simply Right-Click on the Column Header, in the Datasheet/Subform, and do the Sort?

Linq ;0)>
 

Users who are viewing this thread

Back
Top Bottom