sorting a subform

  • Thread starter Thread starter Mary
  • Start date Start date
The first thought would be to sort your data Desc in the query your subform is
based on. Apparently you can't do that if you want to programatically set Desc.

One way to do what you want is to make a copy of the query your form is based on
and set it to sort Desc. Then put this code in an event on your main form:

Me!NameOfSubformControl.Form.Recordsource = "NameOfCopyQuery"
Me!NameOfSubformControl.Form.Requery
 
Try:

Me.SubformControl.Form.OrderBy = "[SortField] DESC"
Me.SubformControl.Form.OrderByOn = True

[SortField] must be a Field in the Subform's RecordSource.

HTH
Van T. Dinh
MVP (Access)
 
Check Knowledge Base article 208390 (How to sort form records using combo
box selection)


Van T. Dinh said:
Try:

Me.SubformControl.Form.OrderBy = "[SortField] DESC"
Me.SubformControl.Form.OrderByOn = True

[SortField] must be a Field in the Subform's RecordSource.

HTH
Van T. Dinh
MVP (Access)


-----Original Message-----
I have a subform on a form that I need to sort "Desc" in
code from the main form.

Thanks
.
 
Back
Top