How to change OrderBy property of a subform from the main form? (1 Viewer)

lana

Registered User.
Local time
Today, 11:25
Joined
Feb 10, 2010
Messages
92
Hi there,
I have a form with a subform. The recordsource of the subform is a table.
When the user changes the sort order of one of the fields in the subform, this sort order stays until the form is closed.
I need to change this sort order by VBA.
Any ideas?
Thanks a lot
 

June7

AWF VIP
Local time
Yesterday, 22:55
Joined
Mar 9, 2014
Messages
5,470
Set the form's OrderBy and/or OrderByOn properties.

Do you want to remove sort?

Forms!mainformname.subformcontainername.Form.OrderBy = ""

Forms!mainformname.subformcontainername.Form.OrderByOn = False
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 14:55
Joined
May 7, 2009
Messages
19,233
you also use DoCmd to remove the Filter:
Code:
With DoCmd
    .GoToControl "subFormName"
    .SetOrderBy ""
End With

you can add a Button on the main form the "Clear" the sorting.
 

lana

Registered User.
Local time
Today, 11:25
Joined
Feb 10, 2010
Messages
92
God bless you.
Thanks so much.
 

Users who are viewing this thread

Top Bottom