Sorting a report

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to let the user select how they want to sort a report. I've give the
user a message which they respond to with a Yes or No. I then test the
response and if Yes I set the me.orderby = "lastName" and if No I set the
me.orderby = "acctNumber" I have also set the me.orderbyon = true. I then do
the docmd.openreport (formName), , stdcriteria (which is set to a where
clause) the where clause works but the orderby doesn't do anything. What am
I doing wrong. Thanks for any help.

CD Tom
 
CD said:
I want to let the user select how they want to sort a report. I've give the
user a message which they respond to with a Yes or No. I then test the
response and if Yes I set the me.orderby = "lastName" and if No I set the
me.orderby = "acctNumber" I have also set the me.orderbyon = true. I then do
the docmd.openreport (formName), , stdcriteria (which is set to a where
clause) the where clause works but the orderby doesn't do anything.


You can not set a report's OrderBy property before you open
the report.

The sorting in any non-trivial report can only be done
reliably by using the report's Sorting and Grouping window
(View menu). Once you have specified a sort/group level,
you can modify it in the report's Open event using code
like:

Me.GroupLevel(x).ControlSource = "acctNumber"
 
Back
Top