order by

  • Thread starter Thread starter 123
  • Start date Start date
1

123

Thank you for your help and answer:

Whey this code not work and what is the solution

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

Notes:
I want to use report order by to sort report by using the report open event
( by using text box in open form)
Thank you
 
123 said:
Whey this code not work and what is the solution

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

Notes:
I want to use report order by to sort report by using the report open event
( by using text box in open form)


You also have to set the OrderByOn property for the OrderBy
to take effect:

Me.OrderBy = Forms![Report]![txts]
Me.OrderByOn = True

But be aware that if you have specified anything in the
report Sorting and Grouping, the above may not produce the
desired results.

To be certain of how your report is sorted, you should not
use the OrderBy property, use Sorting and Grouping instead.

After specifying the default field to sort on, you can reset
the field that you want to sort on in the report's Open
event with code like:

Me.GroupLevel(N).ControlSource = Forms![Report]![txts]
 
Thank you for your help and answer:

Whey this code not work and what is the solution

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

Notes:
I want to use report order by to sort report by using the report open event
( by using text box in open form)
Thank you


If the report has any sort in it's Sorting and Grouping dialog, that
will override any sort you wish place in the report's OrderBy
property.

If there is NO sort in the Sorting and Grouping dialog, you can get
the sort field from a form text control into the Report like this:

Private Sub Report_Open(Cancel As Integer)
Me.OrderBy = forms!NameOfForm!ControlName
Me.OrderByOn = True
End Sub

The Form MUST be open when the report is opened.
The form control MUST contain the valid name of a field.
 
Back
Top