|
-
Jun 22nd, 2006, 03:43 PM
#1
Thread Starter
New Member
Multiple Order by's in a Record SelectionFormula
Here is the code I am running. I am attempting to specify a 2nd and 3rd order by with no luck.
Dim selectionFormula As String = "{Invoice_Header.SRF-CustomerNumber} = " & Session("SRF-CustNo")
selectionFormula = selectionFormula & " AND {Invoice_Header.Invoice Date} >= #" & Format(CDate(Session("SDT")), "MM/dd/yyyy") & " 00:00:01#"
selectionFormula = selectionFormula & " AND {Invoice_Header.Invoice Date} <= #" & Format(CDate(Session("EDT")), "MM/dd/yyyy") & " 23:59:59#"
If Session("TechNo") <> "" Then
selectionFormula = selectionFormula & " AND {Invoice_Header.Tech Number} = '" & Session("TechNo") & "'"
End If
selectionFormula = selectionFormula & " Order by {Invoice_Header.Tech Number} "
'
' PROBLEM IS IN THE next 2 Lines
'
selectionFormula = selectionFormula & " by {Invoice_Header.Invoice Number} "
selectionFormula = selectionFormula & " by {Invoice_Header.Invoice Line Number} "
InvoiceRegister.DataDefinition.RecordSelectionFormula = selectionFormula
CrystalReportViewer1.ReportSource = InvoiceRegister
-
Jun 22nd, 2006, 04:41 PM
#2
Re: Multiple Order by's in a Record SelectionFormula
Welcome to VBForums! 
I don't know if Crystal uses a "normal" SQL order-by clause, but if it does it should be like this:
VB Code:
selectionFormula = selectionFormula & " , {Invoice_Header.Invoice Number} "
..as items to be "ordered by" need to be separated by commas.
-
Jun 22nd, 2006, 04:51 PM
#3
Thread Starter
New Member
Re: Multiple Order by's in a Record SelectionFormula
I've tried commas, bys,thens
-
Jun 22nd, 2006, 05:00 PM
#4
Re: Multiple Order by's in a Record SelectionFormula
Strange.. i would have expected it to be "normal" and use commas. Unfortunately I dont have access to Crystal, so I cannot find an answer for you - but perhaps you can find something in the help, or by experimenting in the program itself.
-
Jun 23rd, 2006, 12:34 PM
#5
Re: Multiple Order by's in a Record SelectionFormula
The RecordSelection Formula is only used to restrict which records are included in the report. If possible Crystal will include the formula statements in the Where clause that it sends to the database, otherwise it will process them after execution of the sql statement.
I don't know what version of Crystal you are using but its object model should expose the ability to set the Sort order. In 8.5 it is called Report.ReportSortFields
-
Jun 23rd, 2006, 01:15 PM
#6
Thread Starter
New Member
Re: Multiple Order by's in a Record SelectionFormula
Any Chance I could get a VB snippet on how to do the sort code with the multiple order bys from my example. The web (As usual) Has No Examples at all on how to do this.
Thanks for all your help.
-
Jun 23rd, 2006, 01:17 PM
#7
Thread Starter
New Member
Re: Multiple Order by's in a Record SelectionFormula
Sorry, the version I have is the one included with VS 2005
-
Jun 23rd, 2006, 02:12 PM
#8
Thread Starter
New Member
Re: Multiple Order by's in a Record SelectionFormula
Some Progrress:
I've gotten this far and I think I am almost there, I have a typo or somthing on the 3rd criteria, but #0 and #1 appear to work using this code
Dim crDatabaseFieldDefinition As CrystalDecisions.CrystalReports.Engine.DatabaseFieldDefinition
crDatabaseFieldDefinition = InvoiceRegister.Database.Tables("Invoice_Header").Fields("Tech Number")
InvoiceRegister.DataDefinition.SortFields.Item(0).field = crDatabaseFieldDefinition
crDatabaseFieldDefinition = InvoiceRegister.Database.Tables("Invoice_Header").Fields("Invoice Number")
InvoiceRegister.DataDefinition.SortFields.Item(1).field = crDatabaseFieldDefinition
crDatabaseFieldDefinition = InvoiceRegister.Database.Tables("Invoice_Line_Items").Fields("Invoice Line Number")
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|