Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dynamically changing a grouping/sorting level

Status
Not open for further replies.

jen89

Programmer
Aug 16, 2001
105
US
I am trying to produce a report with one level of grouping on [Vendor]. Within the group, I need to sort by one field. (either [Project Name] or [Invoice Date]) I can do this by hand if I open the sorting and grouping window and add the desired field as a second Field/Expression (after [Vendor]) and choose ascending.

The problem is that I need to be able to choose the sort order on the form that opens the report. Changing the SQL doesn't seem to help, so I think I need to find a way to dynamically control the actual group level. Can anyone tell me how I could either create a new group level (i.e. creategrouplevel(reportname, "[project name]",0,0)) or modify a preexisting one? (i.e. Me.grouplevel(1) = [project name] or Me.grouplevel(1) = [invoice date])

I can't seem to use creategrouplevel unless I first open the report in design view, change it, then open it in normal view. But this actually modifies the report, which I don't want. I am just lost as to how I can control this through code. Please, if anyone has even the slightest idea, please let me know! thanks!
 
To change the 'Actual' grouping and sorting, you MUST have the report open in Design View. You can do this progrmatically, and the report does not need to be visible. Just glancing at your post, it looks like you are able to do this with only the 'hint' re open design view, hidden. Make your change(s). Switch to preview. Should work.

An alternative -which I prefer- is to create a calculated field in the recordsource. Use this calculated field in the sorting / grouping. In the process of generating the recordsource, set the calculated field to which-ever field (or even expression) desired.

MichaelRed
m.red@att.net

There is never time to do it right but there is always time to do it over
 
okay, I think I got it. Thanks for your advice Michael - I didn't know you could put a report in design view w/out it being visible. I actually got it to work by assigning

me.grouplevel(1) = [invoice date]

in the actual report.


then, I changed it to

me.grouplevel(1).controlsource = [program name]

in the code if they chose that. It seems to work fine. I was sure I had tried that already :) If anyone knows of any unpleasent side effects of that method, please let me know
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top