Report overrides Order by clause of its recordsource query

  • Thread starter Thread starter Mota
  • Start date Start date
M

Mota

Hi;
I use Access 2000 and have a report based on a query.Although when i open
that query,records are ordered perfect,opening report is not the same as
its bound query,until i manually enter the ordering fields in property sheet
of the report,that is not possible always.In fact the report orders its
records based on the Primary Key of the table the query is based on.I want
records be ordered just like the query (that i can control its SQL property
thru code) that this report is bound to.setting the order by property of the
report in its property sheet to True or False has no effect.Can anyone
please help me?
Thank you in advance.
 
If you understand the code to write to the sql property of a query then you
shouldn't have much trouble with the code at Allen Browne's site
http://allenbrowne.com/ser-33.html. This code sets the grouping/sorting leve
control source at run-time.

I prefer to never rely on either the order in the recordsource query or the
Order By property of the report.
 
This is a good idea but is a predefined solution.so,how i cant take control
on a report thru my code?For example,when i want to define another ordering
for this report based some conditions happens before opening it,how can i
put this code snipet in Open Event of the report?Is there a way to set
number of grouping levels and then ordering it programmatically before
opening a report?
Thank you so much for ur help.
 
The suggested solution assumes you have levels "pre-defined". The levels can
be constants like "=1" if you don't want to use them.

The code is placed in the On Open event of the report.
 
Back
Top