Sort Order on Reports

S

Sue

Hi All.

I have a default sort order set in the sorting and
grouping of my report. However, I allow the user to
specify whatever sort they wish based on the fields in
the report using a QBF from with filters and sort options.

I am using VB to set the Orderby and OrderbyOn
properties. This does NOT change the sort order UNLESS I
remove the default sort order from within the report. It
still sorts based on the sorting specified in the report
itself. There are no Groups.

Help!
If Len(Trim(sOrderBy)) > 0 Then
Reports(sTheReport).OrderByOn = True
Reports(sTheReport).OrderBy = sOrderBy
End If
If Len(Trim(sSqlFilter)) > 0 Then
Reports(sTheReport).FilterOn = True
Reports(sTheReport).Filter = sSqlFilter
End If
End If

Thanks in advance for saving what's left of my hair!

Sue
 
M

Marshall Barton

Sue said:
I have a default sort order set in the sorting and
grouping of my report. However, I allow the user to
specify whatever sort they wish based on the fields in
the report using a QBF from with filters and sort options.

I am using VB to set the Orderby and OrderbyOn
properties. This does NOT change the sort order UNLESS I
remove the default sort order from within the report. It
still sorts based on the sorting specified in the report
itself. There are no Groups.

Help!
If Len(Trim(sOrderBy)) > 0 Then
Reports(sTheReport).OrderByOn = True
Reports(sTheReport).OrderBy = sOrderBy
End If
If Len(Trim(sSqlFilter)) > 0 Then
Reports(sTheReport).FilterOn = True
Reports(sTheReport).Filter = sSqlFilter
End If
End If


Sorting and Grouping takes precedence over all other ways of
sorting a report. You can skip the OrderBy stuff and reset
the sort field in the report's Open event:

Me.GroupLevel(0).ControlSource = sOrderBy

You can avoid the use of the Filter property by specifying
the filtering expression in the OpenReport method's
WhereCondition argument.
 

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