conditional sorting

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

Guest

i have a report that prints theatre bookings between 2 dates specified by the
user.
the user will sometimes want to view the report sorted by the number of
bookings or sorted by the £ value of the bookings.
can anybody suggest a way to allow the user to specify which option they
want using 1 report , i am using 2 reports at the moment, one for each
senario (clumbsy and inefficient).
any help would be appreciated. thanks.
 
In the form that you use to open the report, create a combo that contain the
fields you want to sort by, and let the user select one, the combo will
include two columns:
1. A name that make sense for the user
2. The name of the fields (that you want to sort by) in the table

With the OpenReport command line you can a pass the selection of the combo
using the OpenArgs

Docmd.OpenReport "ReportName",,,,,Me.ComboName

On the on open event of the report write the code
Me.OrderBy = Me.OpenArgs
Me.OrderByOn = True
 
thanks for the quick reply ofer.
i will have a go at your suggestion and let you know how i got on.
 
faffy said:
i have a report that prints theatre bookings between 2 dates specified by the
user.
the user will sometimes want to view the report sorted by the number of
bookings or sorted by the £ value of the bookings.
can anybody suggest a way to allow the user to specify which option they
want using 1 report , i am using 2 reports at the moment, one for each
senario (clumbsy and inefficient).
any help would be appreciated. thanks.


You need a way for users to specify what field they want to
sort by. A common approach it to use a form with an option
group, combo box or ... along with text box for the date
range and a button to open the report.

Once you determine how you are going to specify the field,
you can use the report's Open event to change what you have
in the report's Sorting and Grouping. The essence of the
procedure would be:

Me.GroupLevel(XX).ControlSource = fieldnameonform
 
thanks marshall, will take a look at you suggestion in the morning and post
how i get on with it.
 
Back
Top