How to use a docmd ina command box in parent form (1 Viewer)

chrisjames25

Registered User.
Local time
Today, 13:48
Joined
Dec 1, 2014
Messages
401
HI

I have a form with a suform within it. I have a command button in the parent form that i want to use to remove sort from the subform. I originally had this button in subform but for look and fell i think best in parent form.

Code i am using for remove sort in effect just applies the orginal sort back ot the subform:

Code:
DoCmd.SetOrderBy "Category ASC, Genus ASC, Variety ASC"

Do i need to set the focus back to a control in the subform before running the above code or is this not right approach?
 

June7

AWF VIP
Local time
Today, 05:48
Joined
Mar 9, 2014
Messages
5,423
That code will apply to the object it sits behind.

You will have to set the OrderBy property of subform. Suggest naming subform container different from the object it holds, like ctrDetails.

Me.ctrDetails.Form.OrderBy = "Category ASC, Genus ASC, Variety ASC"
Me.ctrDetails.OrderByOn = True
 
Last edited:

Users who are viewing this thread

Top Bottom