How do I sort a report with a macro

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

Guest

How do I sort a report with macros? I want to have one report sorted a
number of different ways by just having a button with a macro for each sort.
Currently, I have to have either multiple reports or multiple queries which
is bogging down my database.

Thanks,

Ron
 
Ron,

Well, this is not really a job for a macro.

One approach would be to put an Option Group on a form, with a choice
for each of the fields you want to sort by, and then in the
Field/Expression column of your report's Sorting & Grouping dialog, you
can put the equivalent of...

=Choose([Forms]![YourForm]![OptionGroupName],[1stSortField],[2ndSortField],[3rdSortField])
 
That is perfect. Can i also use this as a filter; to filter a report by a
field for say 'not null' records?

Steve Schapel said:
Ron,

Well, this is not really a job for a macro.

One approach would be to put an Option Group on a form, with a choice
for each of the fields you want to sort by, and then in the
Field/Expression column of your report's Sorting & Grouping dialog, you
can put the equivalent of...

=Choose([Forms]![YourForm]![OptionGroupName],[1stSortField],[2ndSortField],[3rdSortField])

--
Steve Schapel, Microsoft Access MVP

How do I sort a report with macros? I want to have one report sorted a
number of different ways by just having a button with a macro for each sort.
Currently, I have to have either multiple reports or multiple queries which
is bogging down my database.

Thanks,

Ron
 
Ron,

No, not in the Sorting & Grouping section. I think this would need to
be controlled via the criteria in your query. Either that, or a Where
Condition argument on your OpenReport statement.
 
Back
Top