I have a report that I am generating
based on a query. My problem is that
the query results are shown in the order
they were entered into the table (which
is the way I want them), but on the
report, the lines are random. I would
like to know how to force Access to
put the results of this particular query
in the report in the order they were
entered. I am just using a filter in the
report to display the information I want.
Access follows the relational rule that records are, by definition,
unordered. Because Access must display them in _some_ order, you may see
them in the order they were entered, particularly if you are using an
AutoNumber field as a Primary Key. To ensure some particular order, the
record must contain a field that you can use to define it.
In queries, to ensure order, you must specify the fields on which to sort
(or hope that it will be retrieved in Primary Key order, if that is useful).
In reports, the Report's Sorting and Grouping properties determine the
order. Any ordering in the underlying Query is immaterial because it is
ignored. In Design View of the Report, right-click the upperleftmost little
square, and choose "Sorting and Grouping".
And, if you are thinking, "if I DON'T specify sorting and grouping, why
doesn't the report use the order in which I retrieved the data in my Query,"
rest assured that you are not the first to think that, and that Microsoft
has heard that many times. It's possible that may be changed in some future
release, but how they choose what to implement in particular releases is a
mystery to those of us "on the outside" ("on the outside" includes MVPS, who
are not Microsoft employees).
Larry Linson
Microsoft Access MVPs