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

lana

Registered User.
Local time
Tomorrow, 02:26
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
Today, 13:56
Joined
Mar 9, 2014
Messages
5,465
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
Tomorrow, 05:56
Joined
May 7, 2009
Messages
19,231
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
Tomorrow, 02:26
Joined
Feb 10, 2010
Messages
92
God bless you.
Thanks so much.
 

Users who are viewing this thread

Top Bottom