Full Version: "kind Of" Sorting By Fielda
UtterAccess Discussion Forums > Microsoft® Access > Access Forms
cliff021668
Alright, UtterAccess family... here's a good Friday-morning question:

I have a report with 3000 records. Currently, the entire report is sorted by field SampleDate.

There is another field, FieldA, that contains the following possible values: RF, LF, RR, LR, CO.

My customer would like the report to show all the CO values (from FieldA) at the top of the report...

But, all the other records should continue to be sorted by field SampleDate.

So, I'm "kind of" sorting by FieldA... sorting just enough to compile all CO's at the top of the report...

Any thoughts how I might best accomplish this?

Cliff
niesz
Add a Calculated field to the underlying query:

PrimarySort: IIF(FieldA = 'CO',0,1)

Then sort by PrimarySort, then SampleDate.
MikeLyons
Perhaps add a column to the query that tests for CO. If it is CO, assign it the value 1, otherwise the value 2 (a simple IIF() call may suffice)

Then in the report, you can use the sorting and grouping to sort on that column to ensure the CO records come first.


Edit: I posted and see another person gave a similar suggestion.

Mike
theDBguy
Hi Cliff,

When I have to do complex sorting, I usually add a sorting field. But since you only have two sorting requirement, maybe you could just create two subreports.

Just my 2 cents... 2cents.gif

EDIT: Oops, guess I'm too slow today. smile.gif
datAdrenaline
In the sorting specifications of the Report object, create an Expression the provides your sort key ...


=IIf([FieldA] = "CO","A", "Z")

Then your your SampleDate as the secondary sort criteria
cliff021668
MAN! I L-O-V-E this place (meaning, "UtterAccess")!

You guys rock!

Yes, yes... it worked like a charm.

Makes me wanna go do an awkward victory lap around the office, high-fiving coworkers I've never met!

Woo hoo!

Thx, everyone.

Cliff
niesz
thumbup.gif
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.