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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sorting Records on the report output itself

Status
Not open for further replies.

mchoss

Programmer
Feb 11, 2002
87
GB
Office XP and 2000.

Apologies if this is a very simple and obvious task, however i want to be able to alter the sorting of a report once the output is generated (ie, the user can change the column sorting as they view the report - not at design time). I guess what i am looking for is the ability to change the sorting by clicking a column heading.

I have tried adding a control that might run a macro or something to alter the sort order but i don't really think i am getting there so to speak.

Am i right in thinking this must be really easy to implement but i just don't know how?

Any help would be greatly appreciated.
 
You can't change the Report once it's been open, so what you need to do is build a "controller" form. You could place a dropdown (or a number of buttons) on a form, and on selection or click you change the Report's source and use an Event Sub to open the Report based on your SQL statment, like...

' Build our custom SQL
txtSQL = "Select * from tblTable Order By " & cboField
' close the controller form
DoCmd.Close acForm, "frmReports"
' open the report based on a custom RecordSource
DoCmd.OpenReport "rptStatus", acPreview, , txtSQL

Hope this helps
 
Murky Bucket comaboy.

i suspected as much but wanted to be certain there was not a very simple way i had missed/not discovered.

Much thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top