Command button to Sort

K

Keith Ward

Hi,

I have a form with a subform which contains fields I don't want to see but
want to sort by.

I would like to put a command button in the top form which when clicked
sorts the subform by the invisible field by a-z.

How do I achieve this in code?

Thanks

Keith
 
A

Allen Browne

Use this kind of thing in the Event procedure for your command button:

Private Sub cmdSort_Click()
If Me.Dirty Then Me.Dirty = False
Me.OrderBy = "[NameOfYourFieldHere]"
Me.OrderByOn = True
End Sub
 
Top