sorting a subform

M

Mary

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

Thanks
 
T

Tom

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
 
V

Van T. Dinh

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)
 
M

Mary Fetsch

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
.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top