- Local time
- Today, 01:35
- Joined
- Feb 28, 2001
- Messages
- 27,156
Since you are not doing a report grouping, you have essentially at most five sections: Report Header and Footer, Page Header and Footer, and Detail. None of those headers and footers care about order, so all you want is that the Detail section appears in a particular order. In theory, if you set the report's .OrderBy to the fields you want sorted in the priority order you desire, that should work.
However, here is my question: When will you know the correct order that you wanted to use? This is crucial to making it easier or harder to accomplish your task. I will explain.
If you cannot know until the report is already open, something is wrong because that means you are doing your logic inside a report event. That is just WRONG. Way too late in the binding. BUT if you know the right order just a few steps earlier, you can impose a sort order when you issue the DoCmd.OpenReport command that launches the report. And from there, you can perhaps use a fixed .Recordsource that doesn't change across multiple iterations - but you can use a dynamically defined .OrderBy to choose the order. Will that work?
The reason I ask this is that report definitions are bound to the .Recordsource by field names, so the query you are using HAS to be at least THAT predictable - i.e. that you have the field definitions already bound. The order? That can be dynamic. But the field bindings? That is a whole other ball of wax.
However, here is my question: When will you know the correct order that you wanted to use? This is crucial to making it easier or harder to accomplish your task. I will explain.
If you cannot know until the report is already open, something is wrong because that means you are doing your logic inside a report event. That is just WRONG. Way too late in the binding. BUT if you know the right order just a few steps earlier, you can impose a sort order when you issue the DoCmd.OpenReport command that launches the report. And from there, you can perhaps use a fixed .Recordsource that doesn't change across multiple iterations - but you can use a dynamically defined .OrderBy to choose the order. Will that work?
The reason I ask this is that report definitions are bound to the .Recordsource by field names, so the query you are using HAS to be at least THAT predictable - i.e. that you have the field definitions already bound. The order? That can be dynamic. But the field bindings? That is a whole other ball of wax.