J
J_Goddard via AccessMonster.com
Good day -
Using Access 2000.
I have a main report with two subreports. What I want to be able to do is
allow my users to select the sort order to be used on one of the subreports
(there are 5 options).
The main report and the two subreports are each based on separate queries.
In the form the used to set up the report specifcations, users select the
sort option to be used, and then use code to change to change the SQL of the
query which is the recordsource of the subreport:
Select Case Me!SortOrder ' User selects the sort order on the form
Case 1
CurrentDb.QueryDefs![corcas case report query].SQL = querySQL & _
" ORDER BY [module number], [KPath Number] desc;"
Case 2
CurrentDb.QueryDefs![corcas case report query].SQL = querySQL & _
" ORDER BY [module number], [countofpts]/[cluster size]*100 desc;"
'
' etc for 5 choices
'
End Select
I know this works, because I can go to the query [corcas case report query]
and see the changes have been made correctly.
However, when I run the main report, the subreport is not sorted correctly -
to the user it is not sorted at all - it is sorted on a field which is in the
underlying query, but is not part of the report.
- I have deleted grouping/sort order in the sub-report
- the sub-report is linked to the subreport through one field ([module number]
)
- changing the recordsource in the on-open of the subreport generates an
error
It appears the the sub-report does not recognize the sorting specified in its
source query.
Is there any way to accomplish what I am trying to do?
Thanks all
John
Using Access 2000.
I have a main report with two subreports. What I want to be able to do is
allow my users to select the sort order to be used on one of the subreports
(there are 5 options).
The main report and the two subreports are each based on separate queries.
In the form the used to set up the report specifcations, users select the
sort option to be used, and then use code to change to change the SQL of the
query which is the recordsource of the subreport:
Select Case Me!SortOrder ' User selects the sort order on the form
Case 1
CurrentDb.QueryDefs![corcas case report query].SQL = querySQL & _
" ORDER BY [module number], [KPath Number] desc;"
Case 2
CurrentDb.QueryDefs![corcas case report query].SQL = querySQL & _
" ORDER BY [module number], [countofpts]/[cluster size]*100 desc;"
'
' etc for 5 choices
'
End Select
I know this works, because I can go to the query [corcas case report query]
and see the changes have been made correctly.
However, when I run the main report, the subreport is not sorted correctly -
to the user it is not sorted at all - it is sorted on a field which is in the
underlying query, but is not part of the report.
- I have deleted grouping/sort order in the sub-report
- the sub-report is linked to the subreport through one field ([module number]
)
- changing the recordsource in the on-open of the subreport generates an
error
It appears the the sub-report does not recognize the sorting specified in its
source query.
Is there any way to accomplish what I am trying to do?
Thanks all
John