Dynamically sort reports

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
 
C

Cameron Sutherland

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
 
D

Dave

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
.
.
 

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