Sort on report at run time?

K

kai

Hi,
I connect RecordSource of a report at run time to a predefined query (use
Query designer). I set "sort order" in "Audit Date" column (Ascending).
But when I run the report, it is not sort by "Audit Date", it has no sort
order on any field.

Because the "RecordSource" is not set at design time, I cannot use the
report feature "Group by" to setup sort order. How to set sort order at run
time on a report?

Thanks

Kai
 
M

Marshall Barton

kai said:
I connect RecordSource of a report at run time to a predefined query (use
Query designer). I set "sort order" in "Audit Date" column (Ascending).
But when I run the report, it is not sort by "Audit Date", it has no sort
order on any field.

Because the "RecordSource" is not set at design time, I cannot use the
report feature "Group by" to setup sort order. How to set sort order at run
time on a report?


The query's Order By clause is a waste of time in all but
the most trivial reports. You really need to find a way to
use the report's Sorting and Grouping.

If you specify a field (any field) for the report to sort
on, you can change it in the report's Open event.

Me.GroupLevel(N).ControlSource = "field to sort on"

Where N is the zero based index into the sort/group list.
 
K

kai

Marshall
Thanks a lot, it works.
Kai
Marshall Barton said:
The query's Order By clause is a waste of time in all but
the most trivial reports. You really need to find a way to
use the report's Sorting and Grouping.

If you specify a field (any field) for the report to sort
on, you can change it in the report's Open event.

Me.GroupLevel(N).ControlSource = "field to sort on"

Where N is the zero based index into the sort/group list.
 

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