Results 1 to 3 of 3

Thread: [RESOLVED] Crystal Sort Order

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2005
    Location
    Chesterfield, UK
    Posts
    162

    Resolved [RESOLVED] Crystal Sort Order

    Can anybody see why the following code doesn't work. VB.Net doesn't grumble but it doesn't run the report and promptly exits the program without any errors. If I comment out the code it works fine.

    The report already has two sort fields but I just need to change the sort order.

    VB Code:
    1. Dim sField1 As CrystalDecisions.CrystalReports.Engine.DatabaseFieldDefinition
    2. sField1 = x.cr.Database.Tables.Item(0).Fields("sales_order")
    3. x.cr.DataDefinition.SortFields.Item(0).Field = sField1

  2. #2
    New Member
    Join Date
    May 2006
    Posts
    2

    Re: Crystal Sort Order

    Which CR version ?

    In CR 11, I used this, and it works fine :

    VB Code:
    1. Call x.cr.RecordSortFields.Add(x.cr.Database.Tables(1).Fields.GetItemByName("sales_order"), crAscendingOrder)

    Hope it'll help.

    Nathy1210

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Aug 2005
    Location
    Chesterfield, UK
    Posts
    162

    Re: Crystal Sort Order

    Thanks, I'll give it a try but I did get round it by using grouping.

    VB Code:
    1. Select Case CcbsCombo1.SelectedIndex
    2.             Case 0 'by line
    3.  
    4.             Case 1 'by part
    5.                 Dim grpline As CrystalDecisions.CrystalReports.Engine.FieldDefinition
    6.                 grpline = x.cr.Database.Tables(0).Fields("order_line")
    7.                 x.cr.DataDefinition.Groups(2).ConditionField = grpline
    8.  
    9.                 Dim grppart As CrystalDecisions.CrystalReports.Engine.FieldDefinition
    10.                 grppart = x.cr.Database.Tables(0).Fields("part")
    11.                 x.cr.DataDefinition.Groups(1).ConditionField = grppart
    12.             Case 2 'by bin
    13.                 Dim grppart As CrystalDecisions.CrystalReports.Engine.FieldDefinition
    14.                 grppart = x.cr.Database.Tables(0).Fields("part")
    15.                 x.cr.DataDefinition.Groups(2).ConditionField = grppart
    16.  
    17.                 Dim grpbin As CrystalDecisions.CrystalReports.Engine.FieldDefinition
    18.                 grpbin = x.cr.Database.Tables(0).Fields("bin")
    19.                 x.cr.DataDefinition.Groups(1).ConditionField = grpbin
    20.         End Select

    (I am using CR 11)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width