Problem with Reports and Queries

  • Thread starter John D in London, England
  • Start date
J

John D in London, England

I have several select queries which extract various different sets of records
from a database. The queries all include a sort order specification. I also
have several reports which can use any of the queries. The OnOpen method of
each report receives the name of the required query in openArgs and stores it
in RecordSource.

Most of the reports work fine and list the records in the order specified in
the query. But one particular report gets the order of records wrong. It
lists them in sequence of their autoincrementing record number - i.e.
presumably in the order they are stored in the table. Has anyone seen a
problem like this? - and do you have any solutions.
 
M

Marshall Barton

John said:
I have several select queries which extract various different sets of records
from a database. The queries all include a sort order specification. I also
have several reports which can use any of the queries. The OnOpen method of
each report receives the name of the required query in openArgs and stores it
in RecordSource.

Most of the reports work fine and list the records in the order specified in
the query. But one particular report gets the order of records wrong. It
lists them in sequence of their autoincrementing record number - i.e.
presumably in the order they are stored in the table. Has anyone seen a
problem like this? - and do you have any solutions.


Only trivial reports can sort their records in the record
source query. Sorting in reports needs to be specified in
the report's Sorting and Grouping window (View menu).
 
J

John D in London, England

Thanks very much Marshall, that is most helpful.

Do you by any chance know what constitutes a trivial report? The report that
is giving me trouble is certainly more complicated than the ones that work.
In particular one of the sort keys specified in the query (ForeName) is not
used directly on the report,. It is only used in an expression which merges
it with another field. Could that be my problem?
 
6

'69 Camaro

T

Tom Wickerath

not sure I agree with that



Marshall Barton said:
Only trivial reports can sort their records in the record
source query. Sorting in reports needs to be specified in
the report's Sorting and Grouping window (View menu).
 
J

John Spencer

Try including ForeName as a separate field in the underlying query. Then
you should be able to use it in the report's Sorting and Grouping.

--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 
M

Marshall Barton

John said:
Thanks very much Marshall, that is most helpful.

Do you by any chance know what constitutes a trivial report? The report that
is giving me trouble is certainly more complicated than the ones that work.
In particular one of the sort keys specified in the query (ForeName) is not
used directly on the report,. It is only used in an expression which merges
it with another field. Could that be my problem?


My definition of a trivial report is one that does not use
any grouping and does not use any aggregate functions
(Count, Sum, etc). IOW, a trivial report is not much more
than a dump of the record source table/query.

To specify a sort/group in the report's Sorting and Grouping
list, the field must be in the record source query's field
list. Either do as John said or, if you really want to sort
on the combined value, specify the calculated field.
 

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