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

Sort a dataset for a crystal report

Status
Not open for further replies.

Razzle00

Programmer
Sep 27, 2006
20
US
Hi,

Is there any way to sort a dataset table in code so that your Crystal Report will recognize the sort order. I realize that you can group the data in CR but this will not work for this report. I need it sorted in code before it is passed to CR. Or if this cannot be done can you sort the data in Crystal Reports without using the group fields.

Code:
ds.Tables("history").DefaultView.Sort = "last_name,first_name,access" 
RptDoc.SetDataSource(ds) 
CrystalReportViewer1.ReportSource = RptDoc

Thanks,

Razzle



 
I think (I don't have the code on hand to check) that datatable.defaultview returns a dataview object. So you would want something more like:

Code:
dim dvHistory as dataview = ds.Tables("history").DefaultView
dvHistory.Sort = "last_name,first_name,access"
RptDoc.SetDataSource(dvHistory)
CrystalReportViewer1.ReportSource = RptDoc

-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
Thanks Rick, that worked!

Jbenson, I cannot sort the records from a SQL select statement for this application. Once I pull the records from SQL server, the dataset table is changed from adding/updating/deleting records before its the passed to Crystal Reports.

Razzle
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top