General discussion

  • Creator
    Topic
  • #2177171

    Crystal 8.5 Sort by variable

    Locked

    by walkerxp92 ·

    I am trying to make a report to sort based on what the user selects. For example I have 4 different columns and I want when the user runs the report he selects from the begining what column to sort by. I do not want the user to have to open up the report in crystal and change the sort by.

All Comments

  • Author
    Replies
    • #3351480

      Reply To: Crystal 8.5 Sort by variable

      by walkerxp92 ·

      In reply to Crystal 8.5 Sort by variable

      Point value changed by question poster.

    • #3351213

      Reply To: Crystal 8.5 Sort by variable

      by chandraram ·

      In reply to Crystal 8.5 Sort by variable

      I’ve not used Crystal 8.5, but in earlier versions, I would do this using the SortFields property of the Crystal Reports object.

      • #3351209

        Reply To: Crystal 8.5 Sort by variable

        by walkerxp92 ·

        In reply to Reply To: Crystal 8.5 Sort by variable

        Not quite what I am looking for… I do know how to choose what to sort but I want to make parameter field that will allow me to choose what column I want to sort by.

    • #3351202

      Reply To: Crystal 8.5 Sort by variable

      by chandraram ·

      In reply to Crystal 8.5 Sort by variable

      By “column” do you mean the column in your report or the table used in the report?

      • #3351198

        Reply To: Crystal 8.5 Sort by variable

        by walkerxp92 ·

        In reply to Reply To: Crystal 8.5 Sort by variable

        column in the report… exp: I have a report that pulls 8 columns from sql and 4 of those I want to sort by but not at the same time, I want the report to have a parameter select field in the beginning that asks the user running the report to choose which column to sort by.

    • #3351197

      Reply To: Crystal 8.5 Sort by variable

      by regg ·

      In reply to Crystal 8.5 Sort by variable

      >Not quite what I am looking for… I do know how to choose what to sort but I want to make parameter field that will allow me to choose what column I want to sort by.< But this is what you asked for and the given answer is correct. If the user selects on your form grid a certain column, then: TheFieldName = DataGrid1.Columns(DataGrid1.Col).DataField or TheFieldName = DataGrid1.Columns(DataGrid1.SelStartCol).DataField then you pass that column to CR as a sort parameter. If you are using the OCX then that would be, just as already given: CrystalReport1.SortFields(0) = "+{" & TheTableName & "." & TheFieldName & "}" Because SortFields is an array make sure you you clear any other defined sort parameters (i.e. in a previous printing the sort parameter may have 2 fields defined under SortFields(0) and SortFields(1). If you do not clear SortFields(1)="" then it remains as previously defined. You can also use the Reset method to clear all)

    • #3350956

      Reply To: Crystal 8.5 Sort by variable

      by chandraram ·

      In reply to Crystal 8.5 Sort by variable

      Let us say you have the sql stored in an ADO object – you can present the names of the fields to the user in some form (a listview?) where by any item can be selected, this field name can then be used to set the SortField property of the CR object.

    • #3187812

      Reply To: Crystal 8.5 Sort by variable

      by walkerxp92 ·

      In reply to Crystal 8.5 Sort by variable

      This question was closed by the author

Viewing 5 reply threads