Coding in sort order into a report

  • Thread starter Thread starter TJ Bernard
  • Start date Start date
T

TJ Bernard

I have a simple report with one group (it has a group
header). Under that group there are 10 different fields
(for the entire report as well), and the users have
requested that they be able to sort the data by choosing
from an Option Group which field (they have 4 of the 10 to
choose from).

So I have my form with the option group for the users to
choose the sort order. As of right now depending on their
choice from the option group (can only choose 1) the query
for the report is built with that field in the "Order By"
clause. Then the report is opened up.

The query is ordering the data correctly, but this is not
being out put by the report. The report just orders the
information under the group in the order it was entered
into the table.

I was wondering if there is a way to code into a report
the sort order under a group? If there is, does anyone
have any examples? If not, no biggie just have to tell the
users this is not feasible.

Thank you for your help,

T.J.
 
Open the report in design view.
Open the Sorting And Grouping dialog.
Underneath the field you are grouping on, enter another field as the one to
sort by within the group: say the most common one.

Now in the Open event procedure of your report, you can set the
ControlSource of the GroupLevel to whichever field you need, depending on
the Value of the option group on your form.

For an example of how to do this, see Andy Baron's article:
Sorting Records in a Report at run-time
at:
http://allenbrowne.com/ser-33.html
In your case you want to leave GroupLevel(0) alone (that's what it's
grouping on), and only change the next one - GroupLevel(1)
 
Works great, thank you

-----Original Message-----
Open the report in design view.
Open the Sorting And Grouping dialog.
Underneath the field you are grouping on, enter another field as the one to
sort by within the group: say the most common one.

Now in the Open event procedure of your report, you can set the
ControlSource of the GroupLevel to whichever field you need, depending on
the Value of the option group on your form.

For an example of how to do this, see Andy Baron's article:
Sorting Records in a Report at run-time
at:
http://allenbrowne.com/ser-33.html
In your case you want to leave GroupLevel(0) alone (that's what it's
grouping on), and only change the next one - GroupLevel (1)

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.




.
 
Back
Top