Sorting a report

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
 
M

Marshall Barton

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"
 

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