title: String Parameter Record Selection Formula
body: <p>First, I'm just beginning to learn reporting, all these versions of Crystal Report is confusing me. Anyway, I used the built in Crystal Reports in VS2008.</p>
  
  <p>I am following <a href="http://csharp.net-informations.com/crystal-reports/csharp-crystal-reports-string-parameter.htm" rel="nofollow">this tutorial</a>. I am having a problem filtering. I need to apply two parameter fields to my report - to sort it according to user type or user status. I have these in a cmb box and a textbox beside it to enter text and filter the report upon button click.</p>
  
  <ol>
  <li>When I applied the filter code to my system (upon button click). The initial code to load the entire report without filters did not work (on formload). It shows a pop up asking me to enter parameter values. </li>
  <li>The filter worked great.. until I added another parameter field and tried to duplicate the effect. I went through the same process. Add a parameter field, right click > Report > Selection Formula > Record selection and then added another line. It didnt work. </li>
  </ol>
  
  <p>In my records selection formula editor, it looks like this.</p>
  
  <pre><code>{UserType.UserType} = {?UserType}
  {UserStatus.UserStatus} = {?UserStatus}
  </code></pre>
  
  <p>I believe I do not know how to assign it to a parameter field. And I dont know how to use the records selection formula editor. </p>
  
  <p>I want the <strong>UserType Parameter field</strong> to have this parameter {UserType.UserType} = {?UserType}
  and the <strong>UserStatus Parameter field</strong> to have {UserStatus.UserStatus} = {?UserStatus}</p>
  
  <p>I need help, I don't know how to phrase my question properly for google. This is my code for the button click. I know the code just repeats itself. If you know of an easier way to do this, please advise.</p>
  
  <pre><code>    private void ShowReport_Btn_Click(object sender, EventArgs e)
      {
          //IF SELECTED
          if (Filter_cmb.SelectedItem.ToString() == "UserType") 
          {
              ReportDocument cryRpt = new ReportDocument();
              TableLogOnInfos crtableLogoninfos = new TableLogOnInfos();
              TableLogOnInfo crtableLogoninfo = new TableLogOnInfo();
              ConnectionInfo crConnectionInfo = new ConnectionInfo();
  
              cryRpt.Load("D:\\MY_THESIS\\WORKING FILES\\WindowsFormsApplication2\\WindowsFormsApplication2\\Reports\\Crystal Reports\\UsersReport.rpt");
              crConnectionInfo.ServerName = "RITZEL-PC\\SQLEXPRESS";
              crConnectionInfo.UserID = "NNIT-Admin";
              crConnectionInfo.Password = "password";
              crConnectionInfo.DatabaseName = "NNIT DB";
  
              Tables CrTables = cryRpt.Database.Tables;
              foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)
              {
                  crtableLogoninfo = CrTable.LogOnInfo;
                  crtableLogoninfo.ConnectionInfo = crConnectionInfo;
                  CrTable.ApplyLogOnInfo(crtableLogoninfo);
              }
  
              ParameterFieldDefinitions crParameterFieldDefinitions;
              ParameterFieldDefinition crParameterFieldDefinition;
              ParameterValues crParameterValues = new ParameterValues();
              ParameterDiscreteValue crParameterDiscreteValue = new ParameterDiscreteValue();
  
              crParameterDiscreteValue.Value = textBox1.Text;
              crParameterFieldDefinitions = cryRpt.DataDefinition.ParameterFields;
              crParameterFieldDefinition = crParameterFieldDefinitions["UserType"];
              crParameterValues = crParameterFieldDefinition.CurrentValues;
  
              crParameterValues.Clear();
              crParameterValues.Add(crParameterDiscreteValue);
              crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);
  
              crystalReportViewer1.ReportSource = cryRpt;
              crystalReportViewer1.Refresh();
          }
          else if (Filter_cmb.SelectedItem.ToString() == "UserStatus") 
          {
              ReportDocument cryRpt = new ReportDocument();
              TableLogOnInfos crtableLogoninfos = new TableLogOnInfos();
              TableLogOnInfo crtableLogoninfo = new TableLogOnInfo();
              ConnectionInfo crConnectionInfo = new ConnectionInfo();
  
              cryRpt.Load("D:\\MY_THESIS\\WORKING FILES\\WindowsFormsApplication2\\WindowsFormsApplication2\\Reports\\Crystal Reports\\UsersReport.rpt");
              crConnectionInfo.ServerName = "RITZEL-PC\\SQLEXPRESS";
              crConnectionInfo.UserID = "NNIT-Admin";
              crConnectionInfo.Password = "password";
              crConnectionInfo.DatabaseName = "NNIT DB";
  
              Tables CrTables = cryRpt.Database.Tables;
              foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)
              {
                  crtableLogoninfo = CrTable.LogOnInfo;
                  crtableLogoninfo.ConnectionInfo = crConnectionInfo;
                  CrTable.ApplyLogOnInfo(crtableLogoninfo);
              }
  
              ParameterFieldDefinitions crParameterFieldDefinitions;
              ParameterFieldDefinition crParameterFieldDefinition;
              ParameterValues crParameterValues = new ParameterValues();
              ParameterDiscreteValue crParameterDiscreteValue = new ParameterDiscreteValue();
  
              crParameterDiscreteValue.Value = textBox1.Text;
              crParameterFieldDefinitions = cryRpt.DataDefinition.ParameterFields;
              crParameterFieldDefinition = crParameterFieldDefinitions["UserStatus"];
              crParameterValues = crParameterFieldDefinition.CurrentValues;
  
              crParameterValues.Clear();
              crParameterValues.Add(crParameterDiscreteValue);
              crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);
  
              crystalReportViewer1.ReportSource = cryRpt;
              crystalReportViewer1.Refresh();
          }
  </code></pre>