Sorting a Subform

  • Thread starter Thread starter TDS
  • Start date Start date
T

TDS

I have a subform that displays in datasheet view. I would like to have
several buttons on the main form that sort the subform by different columns,
asc or desc. I have tried to use a setvalue macro to set the orderby setting
on the form, but that does not work. Also tried setting the record source
prop on the sub form - get an error on this also.

Any suggestions?

Terry
 
I have a subform that displays in datasheet view. I would like to have
several buttons on the main form that sort the subform by different columns,
asc or desc. I have tried to use a setvalue macro to set the orderby setting
on the form, but that does not work. Also tried setting the record source
prop on the sub form - get an error on this also.

You may not be referring to the subform correctly. The correct syntax is:

Me.NameOfYourSubformCONTROL.Form.PropertyOrOther

NameOfYourSubformCONTROL is the name of the Subform control that's on the main form, and may or may not be the name of
the form being used as a subform ... check your syntax carefully and make sure you've got that right

That said: You also must turn OrderBy on:

Me.SubformControl.Form.OrderBy="SomeColumn"
Me.SubformControl.Form.OrderByOn = True

You can also set the Recordsource of the subform with the ORDER BY clause:

Me.SubformControl.Form.Recordsource = "SELECT * FROM SomeTable ORDER BY SomeColumn"

Scott McDaniel
scott@takemeout_infotrakker.com
www.infotrakker.com
 
Back
Top