Dynamically sort reports

  • Thread starter Thread starter Dave
  • Start date Start date
D

Dave

I have created a report that has a form dialog page to
pass parameters to the report which then dynamically
creates the where clause to filter records. This part
works well.

What I would now like to do is include a field on the form
that also allows the user to specify which field to sort
the report on.

Is there a way to pass a value from a form that has a sort
field that the user selects at runtime that can be used to
dynamically sort the report based on that user input?

Thanks,

Dave
 
Through some dropdown choice on your form put the field
you wish to sort on in a textbox (called sortbox in this
example). Then in your report you place this code in the
open event

Private Sub Report_Open(Cancel As Integer)
Me.OrderBy = [Forms]![Form1]![sortbox]
End Sub

Every time the report opens it looks for the field in that
box and orders the report.

-Cameron Sutherland
 
Thanks Cameron,

Just what I needed. Thanks for your help.

Dave
-----Original Message-----
Through some dropdown choice on your form put the field
you wish to sort on in a textbox (called sortbox in this
example). Then in your report you place this code in the
open event

Private Sub Report_Open(Cancel As Integer)
Me.OrderBy = [Forms]![Form1]![sortbox]
End Sub

Every time the report opens it looks for the field in that
box and orders the report.

-Cameron Sutherland
-----Original Message-----
I have created a report that has a form dialog page to
pass parameters to the report which then dynamically
creates the where clause to filter records. This part
works well.

What I would now like to do is include a field on the form
that also allows the user to specify which field to sort
the report on.

Is there a way to pass a value from a form that has a sort
field that the user selects at runtime that can be used to
dynamically sort the report based on that user input?

Thanks,

Dave
.
.
 
Back
Top